-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (37 loc) · 1.47 KB
/
index.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
42
43
const BASE_API = "https://graph.instagram.com/me";
const ACCESS_TOKEN ="IGQVJVMTBNbE1HMHQ3c2ZAWYWxHTV9FNnpRNHVyRS10ODFtdkx3UEJ4SXo0Wkg1c3JSaFo4OWQ5R0cyMW5PSW85VkcxdS1OMzF3cnJqMnBWbWpRY3pycDVVaEJkYkF1RXozRnBNaUxWSnh3ZAjRqTVRhT0huR1h5UWstNnRJ";
const username = document.getElementById("username");
const posts = document.getElementById("posts");
const photos = document.getElementById("photos");
const getUserInfo = async() => {
const response = await fetch(`${BASE_API}?fields=username,media_count&access_token=${ACCESS_TOKEN}`);
const userInfo = await response.json();
username.innerHTML = userInfo.username;
posts.innerHTML = userInfo.media_count;
return userInfo;
}
getUserInfo();
const getUserMediaInfo = async() => {
const response = await fetch(`${BASE_API}/media?fields=media_url,media_type&access_token=${ACCESS_TOKEN}`);
const userMediaInfo = await response.json();
return userMediaInfo;
}
getUserMediaInfo().then((media) => {
media.data.map((mediaInfo) => {
if(mediaInfo.media_type !== 'VIDEO') {
const img = document.createElement("img");
img.style.width = "100px";
img.style.filter = "blur(2px)";
img.src = mediaInfo.media_url;
photos.appendChild(img);
}
});
});
const like = () => {
let icon = document.getElementById('like');
icon.classList.toggle("liked-button");
}
const rotate = () => {
let settingIcon = document.getElementById("settings-icon");
settingIcon.classList.toggle("rotate");
}