-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.js
More file actions
40 lines (38 loc) · 1.58 KB
/
fetch.js
File metadata and controls
40 lines (38 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
const wrapper = document.querySelector('.wrapper');
function createContent(data) {
const content = `
<h1>facts about ${data.username}!</h1>
<p>
${data.username} joined <span class="red">${data.joined}</span>
<br><br>
${data.username} lives in the <span class="red">${data.country}</span>
<br><br>
${data.username} has a status of <span class="red">${data.status}</span>
<br><br>
${data.username} has <span class="red">${data.followers}</span> followers
<br><br>
${data.username} is following <span class="red">${data.following}</span> people
<br><br>
${data.username}'s about me is <span class="red">${data.bio}</span>
<br><br>
${data.username}'s what im working on is <span class="red">${data.work}</span>
<br><br>
${data.username}'s profile picture is <br> <img src="https://cdn2.scratch.mit.edu/get_image/user/${data.id}_60x60.png">
<br><br>
${data.username}'s views are <span class="red">${data.statistics.views}</span>
<br><br>
${data.username}'s loves are <span class="red">${data.statistics.loves}</span>
<br><br>
${data.username}'s favorites are <span class="red">${data.statistics.favorites}</span>
<br><br>
${data.username}'s comments are <span class="red">${data.statistics.comments}</span>
<br><br>
it took ${data.query_time} milliseconds to get this data.
</p>
`;
wrapper.insertAdjacentHTML('beforeend', content);
}
fetch('https://scratchdb.lefty.one/v2/user/info/griffpatch')
.then(response => response.json())
.then(data => createContent(data))
.catch(error => console.log(error));