-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomportamento.js
41 lines (32 loc) · 1.17 KB
/
comportamento.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
function carregar(){
const botao = document.getElementById('botao_buscar')
const input_name = document.getElementById('input_usuario')
botao.onclick = () => {
const usuario = input_name.value
const minhaReq = new Request(`https://api.github.com/users/${usuario}`)
fetch(minhaReq)
.then(response => response.json())
.then(dados => {
const nome = dados.name
preencher(dados)
})
}
}
function preencher(dados){
const h2_usuario_nome = document.getElementById('usuario_nome')
const img_avatar = document.getElementById('avatar')
const bio_usuario = document.getElementById('bio_user')
const seguidores_usuario = document.getElementById('seguidores')
const seguindo_usuario = document.getElementById('seguindo')
const nome = dados.name
const url = dados.avatar_url
const bio = dados.bio
const seguir = dados.followers
const seguindo = dados.following
h2_usuario_nome.innerText = nome
img_avatar.src = url
bio_usuario.innerText = bio
seguidores_usuario.innerText = seguir
seguindo_usuario.innerText = seguindo
}
carregar()