forked from trulyPranav/BoP-PreBuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
49 lines (46 loc) · 1.86 KB
/
Copy pathscripts.js
File metadata and controls
49 lines (46 loc) · 1.86 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
document.getElementById('api1button').addEventListener('click', async () => {
await fetch('https://official-joke-api.appspot.com/random_joke/')
.then(response => response.json())
.then(data => {
document.getElementById('api1displayer').innerText = JSON.stringify(data.setup,null,2)
document.getElementById('api1follower').textContent = JSON.stringify(data.punchline,null,2)
console.log(data)
})
})
document.getElementById('api2button').addEventListener('click', async () => {
await fetch('https://meme-api.com/gimme')
.then(response => response.json())
.then(data => {
len = data.preview.length
document.getElementById('api2displayer').innerHTML = null
document.getElementById('random-image').src = data.preview[len - 1];
console.log(data)
})
})
document.getElementById('api3button').addEventListener('click', async () => {
let title = prompt("Enter a title", "hello");
let paste = prompt("Enter a message", "hello world");
fetch('https://jsonplaceholder.typicode.com/posts', {
method: 'POST',
body: JSON.stringify({
title: title,
body: paste,
userId: 1,
}),
headers: {
'Content-type': 'application/json; charset=UTF-8',
},
})
.then((response) => response.json())
.then((json) => {
console.log(json);
document.getElementById('api3title').innerHTML = json.title;
document.getElementById('api3paste').innerHTML = json.body;
document.getElementById('api3displayer').innerHTML = null
});
})
const text = document.querySelector('.logoText p');
text.innerHTML = text.innerText.split("").map(
(char,i) =>
`<span style="transform:rotate(${i * 14}deg)">${char}</span>`
).join("")