Responsive "chicken soup for the soul" using Axios
Design comparison
Solution retrospective
I have raised the question in Slack but still waiting for a response. This advice generator works well in Chrome but doesn't work in Firefox. I can't figure out what went wrong. Does anybody know how to fix this?
Community feedback
- @elaineleungPosted over 2 years ago
Hi Catherine, I don't know why Firefox is having issues either (I'm a Firefox user); it could be certain security settings in the browser itself. But in any case I just tested your code, and the only issue I'm seeing is that the same advice is being given (which happens due to caching). In any case, here's something you can try:
In your
app.js
file, add a line for generating a random number, and then insert that as a template literal into your URL:dice.addEventListener('click', async function getAdvice() { // random number generated const random = Math.floor(Math.random() * 200); try { const res = await axios.get(`https://api.adviceslip.com/advice/${random}`); // template literal here let advice = res.data.slip; showAdvice(advice); console.log(advice); } catch (e) { console.log('error', e); } });
I notice that your component starts with Advice #0, which can be a bit odd. You can consider inserting a number there (even just any arbitrary one, like 1) just to start with.
Good luck!
Marked as helpful0
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