-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperfil.js
More file actions
49 lines (45 loc) · 1.58 KB
/
Copy pathperfil.js
File metadata and controls
49 lines (45 loc) · 1.58 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
42
43
44
45
46
47
48
49
const params = new URLSearchParams(document.location.search)
const id = params.get("userId")
const url = `https://jsonplaceholder.typicode.com/users/${id}`
console.log(id)
bringData()
//FUNCTIONS
function bringData() {
fetch(url)
.then((response) => response.json())
.then((json) => writeHTML(json))
}
function writeHTML(jsonData) {
document.querySelector(".data").innerHTML += `
<article class="userData">
<h3>${jsonData.name}</h3>
<p><strong>Telephono:</strong> ${jsonData.phone}</p>
<p><strong>User name:</strong> ${jsonData.username}</p>
<p><strong>Email:</strong> <a href="#">${
jsonData.email
} </a></p>
<p><strong>Website:</strong><a href="#"> ${
jsonData.website
}</a></p>
<div class="companyCont">
<span><strong>Company</strong></span>
<ul>
<li>${jsonData.company.name.toUpperCase()}</li>
<li>${jsonData.company.catchPhrase}</li>
<li>${jsonData.company.bs}</li>
</ul>
</div>
<div class="companyCont">
<span><strong>Address</strong></span>
<ul>
<li>${jsonData.address.street}, ${
jsonData.address.suite
}</li>
<li>${jsonData.address.city}, ${
jsonData.address.zipcode
}</li>
</ul>
</div>
</article>
`
}