-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
39 lines (33 loc) · 1.25 KB
/
main.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
/**
* montar os links das redes sociais dinamicamente
*/
const LinksSocialMedia = {
github: 'douglasabnovato',
youtube: 'douglasabnovato',
facebook: 'douglasabnovato',
instagram: 'douglasabnovato',
twitter: 'douglasabnovato'
}
function changeSocialMediaLinks() {
for (let li of socialLinks.children) {// filho de id="socialLinks"
const social = li.getAttribute('class')//o primeiro filho é li class="youtube"
li.children[0].href = `https://${social}.com/${LinksSocialMedia[social]}`
}
}
changeSocialMediaLinks()
/**
* preencher as informações de perfil no html com a resposta com os dados da api do github
*/
function getGitHubProfileInfos() {
const url = `https://api.github.com/users/${LinksSocialMedia.github}`
fetch(url)//chamada a api
.then(response => response.json())//conversão da resposta em json
.then(data => { //com todo o objeto json
userName.textContent = data.name // separar elementos que me interessam e passar para o html correspondente
userBio.textContent = data.bio // h1 id="userName" referenciando o id do elemento no html com propriedade textContent
userLink.href = data.html_url
UserImage.src = data.avatar_url
userLogin.textContent = data.login
})
}
getGitHubProfileInfos()