-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcollection.js
41 lines (30 loc) · 1.08 KB
/
collection.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
const buttons = document.getElementById("buttons")
//***************************COLLECTION PART ****************************************/
//@ts-ignore
function myFetch(data, value) {
let url = "https://swapi.dev/api/" + value
let output = ""
fetch(url)
.then(response => response.json())
.then(data => {
console.log(data)
if (value == 'people') {
//@ts-ignore
data.results.forEach(item => {
output += `
<div class="card p-3 m-3" style="opacity:.8">
<h4 class ="card-title text-center"> ${item.name}</h4>
</div>
`
});
}
//@ts-ignore
results.innerHTML = output
})
}
buttons.addEventListener('click', e => {
//@ts-ignore
let test = myFetch(e.target.innerHTML.trim().toLowerCase())
console.log("test:", test)
console.log("mon target:", e.target)
})