Api not fetching data

Hello! I have learnt the concepts of async await and fetch() method in js and I'm trying to practice it through random quote generator but I'm facing some issues Issue: The api is not fetching the data. I have checked the console tab the event listener is working but it gives me errors on fetching the data I have gotten the api url from a github repo provided in the yt description of a video
const quote = document.querySelector(".quote");
const quoteBtn = document.querySelector(".get-quoteBtn");

async function getQuote() {
console.log("get new quote")
let response = await fetch("https://api.quotable.io/random");
let data = await response.json();
console.log(data);
}

quoteBtn.addEventListener("click",getQuote);
const quote = document.querySelector(".quote");
const quoteBtn = document.querySelector(".get-quoteBtn");

async function getQuote() {
console.log("get new quote")
let response = await fetch("https://api.quotable.io/random");
let data = await response.json();
console.log(data);
}

quoteBtn.addEventListener("click",getQuote);
9 Replies
Jochem
Jochem2mo ago
Please provide the errors
Myra
MyraOP2mo ago
No description
Myra
MyraOP2mo ago
These are the errors in my console i have searched about them and i have seen these suggestions there is not any issue with my Internet and i have also checked for the url its correct
ἔρως
ἔρως2mo ago
that means it can't resolve the name - there's no way to fix this
Jochem
Jochem2mo ago
looks like it's no longer maintained. There's a certificate warning when you go there in your browser, though that shouldn't cause a name not resolved error (but a different one). Here's the issue where folks are discussing this particular API being down: https://github.com/lukePeavey/quotable/issues/257
GitHub
API is down · Issue #257 · lukePeavey/quotable
Hi there, I just wanted to let you know that it looks like your API is currently down. I'm experiencing some issues connecting and wanted to give you a heads up so you can check it out. Thanks ...
Jochem
Jochem2mo ago
there's drop-in alternatives in the comments to that issue, though keep in mind that you're trusting randos on the internet for those links. Use at your own risk (even if it should be minimal)
Myra
MyraOP2mo ago
Okay thanks!
13eck
13eck2mo ago
There's the public API that has a bunch of APIs that you can use in projects like this. You might find one you like
Myra
MyraOP2mo ago
Ok

Did you find this page helpful?