-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (22 loc) · 887 Bytes
/
Copy pathscript.js
File metadata and controls
24 lines (22 loc) · 887 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
async function getQuote() {
fetch('https://officeapi.akashrajpurohit.com/quote/random').then(function (response) {
// The API call was successful!
if (response.ok) {
return response.json();
} else {
return Promise.reject(response);
}
}).then(function (data) {
// This is the JSON from our response
console.log(data);
console.log(data['quote'])
console.log(data['character'])
let url = "https://twitter.com/intent/tweet?text=%22"+encodeURI(data['quote'])+"%22%0a%2D%20"+encodeURI(data['character'])+"%0a&url=https://thatswhatshesaid.pages.dev";
document.getElementById('quote').innerHTML = '"'+ data['quote']+'"';
document.getElementById('character').innerHTML = "- " + data['character'];
document.getElementById('tweet').setAttribute('href',url);
}).catch(function (err) {
// There was an error
console.warn('Something went wrong.', err);
});
}