forked from Mishmoready/Week9
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
70 lines (63 loc) · 1.84 KB
/
script.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
console.log(fetch("https://jsonplaceholder.typicode.com/users"));
fetch("https://jsonplaceholder.typicode.com/users").then((response) =>
console.log(response)
);
fetch("https://jsonplaceholder.typicode.com/users").then((response) =>
console.log(response.json())
);
fetch("https://jsonplaceholder.typicode.com/users")
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log(error));
fetch("https://pokeapi.co/api/v2/pokemon?offset=20&limit=20").then((response) =>
console.log(response)
);
fetch("https://pokeapi.co/api/v2/pokemon?offset=20&limit=20").then((response) =>
console.log(response.json())
);
fetch("https://pokeapi.co/api/v2/pokemon?offset=20&limit=20")
.then((response) => response.json())
.then((result) => console.log(result))
.catch((error) => console.log(error));
async function asyncFunction() {
return 1;
}
console.log(asyncFunction());
async function asyncFetch() {
const response = await fetch("https://jsonplaceholder.typicode.com/users");
const result = await response.json();
console.log(result);
}
asyncFetch();
const asyncFetchPmon = async () => {
const response = await fetch(
"https://pokeapi.co/api/v2/pokemon?offset=20&limit=20"
);
const data = await response.json();
console.log(data);
console.log(data.results);
};
asyncFetchPmon();
const asyncFish = async () => {
try {
const response = await Fetch(
"https://pokeapi.co/api/v2/pokemon?offset=20&limit=20"
);
const result = await response.json();
console.log(result);
} catch (err) {
console.log(err);
}
};
asyncFish();
async function pokefetch() {
try {
const myFetch = await Fetch(
"https://pokeapi.co/api/v2/pokemon?offset=20&limit=20"
);
const result = await response.json();
console.log(myFetch);
} catch (err) {
console.log(err);
}
}