-
Notifications
You must be signed in to change notification settings - Fork 0
/
ES6_9.js
37 lines (33 loc) · 935 Bytes
/
ES6_9.js
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
// console.log('First call');
// setTimeout(()=>{
// console.log('Second one');
// },5000);
// console.log('Third one');
// setTimeout(()=>{
// console.log('Fourth one');
// },300);
// let myfirstpromise = new Promise((resolve,reject)=>{
// let name='Alamin';
// setTimeout( ()=>resolve(name),3000);
// })
// myfirstpromise
// .then( (name)=>{
// console.log(`My name is ${name}`);
// })
fetch("https://jsonplaceholder.typicode.com/users")
.then((respons) => respons.json())
.then((body) => {
const lis = body.map(data=>{
let li = document.createElement('li');
let text = `Name: ${data.name}, Email: ${data.email}`;
let textNode = document.createTextNode(text);
li.appendChild(textNode);
return li;
});
lis.forEach(li => {
document.getElementById('mylist').appendChild(li);
})
})
.catch((err) => {
console.log(err);
});