Should I use an API for the Random Quote project

Looking at the test for the project it looks like it is looking for some kind of API call.

Timeout of 15000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
Error: Timeout of 15000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
    at o.f._timeoutError (https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:159:32523)
    at https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js:159:30654

Is it possible to use an array and still pass the tests?. I was planning on finishing the front end projects and when I got to APIs in the Data Visualisation section I would come back and change the program

Yes, it’s totally fine if you just use an array of quotes. I think you’ll often find the most painful part of all the projects is working with the external APIs. Working through that pain is important [in many respects] as it’ll teach you quite a bit about how to deal with APIs you don’t control, but there isn’t any hard requirement to do it one way or the other. It depends on what you want to focus on, what you want the project to teach you – it’s more than reasonable to use an array of quotes and use the project to learn something specific. For example design (how do you lay out the quotes?), or CSS (how do you translate a design into something the browser understands?) or data structures (should it just be an array of string, or should it be an array of objects, and each object has the quote + some metada?), or rendering that data structure to the DOM, etc etc

For simplicity I opted to use an array of quotes and I’ve got all tests passing… sometimes. Other times tests 8 and/or 9 will fail on a timeout. But it is possible.

1 Like

If you passed the tests only sometimes, you probably have a problem in your code. My guess is it probably has something to do with the way you “randomly” select the quote. You should post a link to your project in a new topic and we can have a look for you.