-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi-dattebayo.js
More file actions
32 lines (29 loc) · 880 Bytes
/
api-dattebayo.js
File metadata and controls
32 lines (29 loc) · 880 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 route = 'characters'
let ids = []
fetch(`https://dattebayo-api.onrender.com/${route}`, {
method: 'GET',
headers: {
Accept: 'application/json'
}
})
.then((response) => response.json())
.then((data) => {
for(let i = 0; i < data.characters.length; i++){
ids[i] = data.characters[i].id;
// console.log(data.characters[i]);
fetch(`https://dattebayo-api.onrender.com/${route}/${ids[i]}`, {
method: "GET",
headers: {
Accept: "application/json",
},
})
.then((response) => response.json())
.then((data) =>
console.log(
`ID: ${ids[i]}\nNome: ${data.name}\nTools: ${data.tools}\n`
)
)
.catch((error) => console.error(error));
}
}
).catch((error) => console.error(error))