-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (38 loc) · 1.11 KB
/
index.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
// console.log(fetch('https://pimpkicks.com.ph/cdn/shop/products/Jordan1LowFootballGreyAluminumWomen_s1.png?v=1651565540')
// .then(response => {
// console.log(response)
// return response.blob();
// })
// .then(blob =>{
// console.log(blob)
// document.querySelector('#myImage').src=URL.createObjectURL(blob)
// })
// .catch(error =>{
// console.log(error)
// })
// )
//id selector
const content=document.querySelector("#content")
//loading page
window.addEventListener("load", () =>{
getUsers()
})
function getUsers(){
let html=""
// https://bscs3a-crud-api.onrender.com/api/members , {mode: "cors"})
fetch("https://bscs3a-crud-api.onrender.com/api/members" , {mode: "cors"})
.then((response) =>{
console.log(response)
return response.json()
})
.then((data)=>{
console.log(data)
data.forEach((element) =>{
html += `<li>${element.first_name} ${element.last_name}</li>`
})
content.innerHTML = html
})
.catch((error) =>{
console.log(error)
})
}