-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (27 loc) · 912 Bytes
/
script.js
File metadata and controls
32 lines (27 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const div = document.querySelector("div");
const span = document.querySelector("span");
let display;
// async function apiFetch() {
// try {
// const result = fetch("https://jsonplaceholder.typicode.com/photos")
// .then((response) => response.json())
// .then((data) =>
// data.forEach((users, i) => {
// console.log(users.url);
// const textNode = document.createTextNode(users.url);
// // const textNodeII = document.createTextNode(i);
// div.appendChild(textNode);
// // span.appendChild(textNodeII);
// })
// );
// } catch (error) {
// console.log(error.message);
// console.log("error occured while fetching");
// }
// }
async function apiResult() {
const res = await fetch("https://jsonplaceholder.typicode.com/comments");
const data = await res.json();
console.log(data);
}
apiResult();