25 lines
719 B
JavaScript
25 lines
719 B
JavaScript
|
const button = document.getElementById("getcucc")
|
||
|
button.addEventListener("click", () =>{
|
||
|
let xhr = new XMLHttpRequest()
|
||
|
|
||
|
xhr.onreadystatechange = () =>{
|
||
|
if (xhr.readyState === 4 && xhr.status === 200){
|
||
|
let adat = JSON.parse(xhr.responseText)
|
||
|
console.log(adat)
|
||
|
|
||
|
let tohtml = ""
|
||
|
|
||
|
for (let user of adat.data){
|
||
|
tohtml += `<h1>${user.first_name}</h1>`
|
||
|
tohtml += `<img src=${user.avatar}><br>`
|
||
|
tohtml += `<h1>${user.email}</h1>`
|
||
|
}
|
||
|
|
||
|
document.getElementById("cucc").innerHTML = tohtml
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
xhr.open("GET", "https://reqres.in/api/users?page=2")
|
||
|
xhr.send()
|
||
|
})
|