-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.js
32 lines (31 loc) · 1004 Bytes
/
tests.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
function fetchData() {
console.log("START FETCH");
fetch("https://reqres.in/api/users")
.then(response => {
console.log(response);
if (!response.ok) {
throw Error("ERROR")
}
return response.json();
})
.then(data => {
console.log(data.data)
const html = data.data.map(user => {
return `
<div class = "user" >
<p><img src="${user.avatar}" alt="${user.first_name}" </p>
<p>Name: ${user.first_name}</p>
<p> Email: ${user.email}</p>
</div >`;
})
.join("");
console.log(html);
document
.querySelector('#allmen')
.insertAdjacentHTML('afterbegin', html)
})
.catch(error => {
console.log(error);
});
}
fetchData();