Design comparison
Solution retrospective
A nice way to practice and interact with 3rd-party APIs.
Any suggestions, tips or advice :) for improving the code are always welcome.
Thank you!
Community feedback
- @YerikAHPosted almost 2 years ago
Hello!! 👋
You can add this:
const response= await fetch(urlAPI, { method: "GET", cache: "no cache", });
The above code is so that it does not cache the tips, it seems that when I click on the button it only gives me a tip. Although this can also be solved by changing the url to
https://api.adviceslip.com/advice/${id}
, and for each request they can change the id with a random number.You can also implement an error handler, in case there is an error in the API.
try { const response = await fetch(urlAPI, { method: "GET", cache: "no-cache", }); if(!response.ok){ throw { // } } } catch (err) { // }
Hope am helpful.
Good job for completing this challenge.
Marked as helpful0@iflucianPosted almost 2 years ago@YerikAH
Hello, Yerik!
I appreciate your advice and give it a try.
Thanks!
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