Skip to content

Commit ed7a205

Browse files
fetch-API-II
1 parent 0c94e34 commit ed7a205

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Loading
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>Fetch API- Part-II</title>
9+
</head>
10+
11+
<body>
12+
<h1>Fetch API Part 2 from url</h1>
13+
<h2>Example</h2>
14+
<button onclick="DisplayOne()">Click</button>
15+
<p id="textOne"></p>
16+
<script src="script.js"></script>
17+
</body>
18+
19+
</html>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Fetch API Part 2, Fetching From URL
2+
let textOne = document.getElementById('textOne');
3+
4+
function DisplayOne() {
5+
fetch('https://jsonplaceholder.typicode.com/todos/1')
6+
.then(response => {
7+
let resp = response;
8+
textOne.innerHTML = resp;
9+
console.log(textOne);
10+
});
11+
}

0 commit comments

Comments
 (0)