Design comparison
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
- @EidenRainPosted about 2 years ago
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 helpful1@HarmoniaCodesPosted about 2 years ago@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 GitHubJoin 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