-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
41 lines (28 loc) · 1.31 KB
/
script.js
File metadata and controls
41 lines (28 loc) · 1.31 KB
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
// fetch("https://api.github.com/users/nadfri")
// .then(reponse=>console.log(reponse))//then retourne la réponse du fetch mais sans format json
// fetch("https://api.github.com/users/nadfri")
// .then(reponse=>console.log(reponse.json()))//reponse en attente
// fetch("https://api.github.com/users/nadfri")
// .then(reponse=>reponse.json())
// .then(reponse2=>console.log(reponse2))//affiche la réponse dans la console
// fetch("https://api.github.com/users/nadfri")
// .then(reponse=>reponse.json())
// .then(reponse2=>console.table(reponse2))//affiche la réponse dans la console sous forme de tableau
// fetch("https://api.github.com/users/nadfri")
// .then(reponse=>reponse.json())
// .then(reponse2=>console.log(reponse2.name))//affiche le name
// fetch("https://api.github.com/users/nadfri")
// .then(reponse=>reponse.json())
// .then(reponse2=>console.log(reponse2.avatar_url))//affiche l'url de l'avatar
btn.onclick = () => {
fetch("https://api.github.com/users/" + champ.value)
.then(reponse => reponse.json())
.then(data => {
output.textContent = "";
output.textContent = `Compte de ${data.name}`;
const img = document.createElement("img");
img.src = data.avatar_url;
img.width="100";
output.appendChild(img);
})
}