-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
43 lines (33 loc) · 1.26 KB
/
script.js
File metadata and controls
43 lines (33 loc) · 1.26 KB
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
33
34
35
36
37
38
39
40
41
42
43
// const user = {
// id: 3,
// name: "saidul Islam"
// };
// const jsonConvert = JSON.stringify(user);
// console.log(jsonConvert); // {"id":3,"name":"saidul Islam"}
fetch('https://jsonplaceholder.typicode.com/users')
.then(response => response.json())
.then(json => displayUsers(json))
.catch(error => console.log(error))
function displayUsers(users){
console.log(users);
const name = users.map(username => username.name);
const email = users.map(username => username.email);
let ul = document.getElementById("display_data");
let ulEmail = document.getElementById("display_email");
// const id = users.map(username => username.id);
// const email = users.map(username => username.email);
// console.log(name , id , email);
displayData(name, ul);
displayData(email, ulEmail);
function displayData(userName, listParent){
for (let i = 0; i < userName.length; i++) {
const element = userName[i];
const li = document.createElement("li");
li.innerText = element;
listParent.appendChild(li);
}
}
}
//Status Code All:
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes