-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
17 lines (15 loc) · 735 Bytes
/
script.js
File metadata and controls
17 lines (15 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function fetchQuote() {
fetch('https://api.quotable.io/random')
.then(response => response.json())
.then(data => {
const quote = data.content;
const author = data.author;
const imageUrl = `https://www.google.com/search?q=${encodeURIComponent(author)}&tbm=isch&tbs=isz:l`;
document.getElementById("quote").innerText = `"${quote}"`;
document.getElementById("author").innerText = `- ${author}`;
document.getElementById("author-image").src = imageUrl;
})
.catch(error => console.error('Error fetching quote:', error));
}
// Call the function to fetch and display a random quote when the page loads
fetchQuote();