-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
39 lines (33 loc) · 1.08 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
/*criação objeto com os dados que substituiirão os links anteriores*/
const LinksSocialMedia = {
github: 'alinenog',
youtube: 'rocketseat',
instagram: 'rocketseat_oficial',
facebook: 'rocketseat',
twitter: 'rocketseat'
}
/*Criando a função*/
function chageSocialMediaLinks() {
for (let li of socialLinks.children) {
const social = li.getAttribute('class')
li.children[0].href = `https://${social}.com/${LinksSocialMedia[social]}`
}
}
/*Chamando a função*/
chageSocialMediaLinks()
/*Trocando os links via API */
function getGitHubProfileInfos() {
const url = `https://api.github.com/users/${LinksSocialMedia.github}`
/*Vai até a Url pega a informação e traz de volta*/
fetch(url)
/*PROMESSA é a resposta quando da certo o retorno */
.then(response => response.json())
.then(data => {
userName.textContent = data.name
userBio.textContent = data.bio
userLink.href = data.html_url
userImage.src = data.avatar_url
userLogin.textContent = data.login
})
}
getGitHubProfileInfos()