Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Advice Generator App using AdviceSlip API

Nick 160

@HarmoniaCodes

Desktop design screenshot for the Advice generator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


When using the randomly generated link from the adviceslip API, the javascript that I wrote would fetch the URI once, then would not reload a different message even if the function was called again. To workaround this, I created a random number generator. This random number is appended to the end of the API uri to get a pseudo-random URI. Is there a better way to do this? What would best practices be?

Community feedback

P
EidenRain 40

@EidenRain

Posted

First of all... great work!

I'll try to answer the question. If the API wouldn't support fetching a random question, your solution would be just fine, I think (even though you limited these great advices to 100 :P).

Try out the 'api.adviceslip.com/advice' endpoint! No '/' at the end.

Marked as helpful

1

Nick 160

@HarmoniaCodes

Posted

@EidenRain Thank you for your comment! It seems like there is some difference in the way that firefox fetches JSON vs. Chrome. The solution you listed does work in chrome, but won't reload the JSON file in firefox. I've noticed that most of the solutions that others have posted for this project don't work in firefox. I'll do some more investigating and try to figure out the reason.

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord