-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.js
More file actions
32 lines (31 loc) · 847 Bytes
/
fetch.js
File metadata and controls
32 lines (31 loc) · 847 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
fetch("https://swapi.dev/api/people/1/")
.then((res) => {
console.log("RESOLVED!!!", res);
return res.json()
})
.then((data) => {
console.log("JSON DONE", data)
return fetch("https://swapi.dev/api/people/2/")
})
.then(res => {
console.log("SECOND REQUEST RESOLVED!!!")
return res.json();
})
.then((data) => {
console.log(data);
})
.catch((e) => {
console.log("ERROR!!!", e);
});
const loadStar= async()=>{
try{const res=await fetch("https://swapi.dev/api/people/1/")
const data=await res.json();
console.log(data)
const res2=await fetch("https://swapi.dev/api/people/2/")
const data2=await res2.json();
console.log(data2)
}catch(e){
console.log("ERROR!!!",e)
}
}
loadStar()