Design comparison
Solution retrospective
This is the first API project I've made without guidance of a tutorial or instruction. I enjoyed building it and I hope to take one more challenges like this soon.
One question, the neon reset button reloads the whole page, is there a better way to re-render the advice data?
Community feedback
- @AndrewKohnPosted over 2 years ago
Looks great!
My suggestion for your question is to try to add an addEventListener() to your button in javascript and remove the onclick on the html, since I believe that was what is making the page refresh. After that, you can set your fetch method into a const variable and use that in the event listener or cut/paste the fetch method directly into the event listener.
1@Akhlak-Hossain-JimPosted over 2 years ago@AndrewKohn nope. Onclick or in addEventListener both have to use the same
refresh
to make a new request. So that won't be effective but if you use other ways.0@michagodfreyPosted over 2 years ago@AndrewKohn Thanks for the feedback! I agree an addEventListener() makes sense and that was my original approach but the way I wrote the code it would only fetch the same quote, i.e. the same slip again and again and not display a new advice. But I noticed refreshing the page generated a new advice so I just made the button do that! A bit of a lazy solution really and I'll figure out a better way for the next one. I noticed many of the other solutions to this challenge use async, I'll look at them.
0 - @Akhlak-Hossain-JimPosted over 2 years ago
Great work for the first time working with API.
But try q instead of p tag for a quote.
1@michagodfreyPosted over 2 years ago@Akhlak-Hossain-Jim Thanks for the tip. I didn't even know <q> tags existed, good to know!
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