Design comparison
Solution retrospective
For some reason it only works one time. I was looking for a solution but i didn't find it
Community feedback
- @elaineleungPosted about 2 years ago
Hi zer0VAns, if you're a Firefox user like I am, you can definitely try adding the request header object mentioned by @Darknessflowers, as that was what solved my problem. I see in your code that you're using the w3 library; I'm not familiar with it so I'm not sure where you'd put the header object since
w3.getHttpObject
takes a callback function, unlike the fetch API which uses promises. If you're up for trying the fetch API along with usingno-cache
, you can use this snippet of code:function getAdvice() { fetch("https://api.adviceslip.com/advice", {cache: "no-cache"}) .then( response => response.json()) .then( data => { const advice = data.slip.advice text.innerHTML = '"' + advice + '"' }) }
One other suggestion is, for the mobile view, I think the advice container can use a bit more padding. Anyway, great work on the whole, especially in getting your solution to look really close to the design!
Marked as helpful1@zer0VAnsPosted about 2 years ago@elaineleung @Darknessflowers Thank you very much! Exactly, i use Firefox, i really did not know about the cache. Right now I fix it (the padding thing too XD). Have a great day!
1 - @DarknessflowersPosted about 2 years ago
I'm not familiar with the way you retrieved it, but I was having the same issue when building mine and the problem was that Firefox was caching it. With mine when fetching I had to add {cache: "no-cache"} to my fetch. I'm not sure what the solution is with the method you used, but I think it is the same problem of Firefox auto-caching it since it does work if you view it in other browsers. I hope that helps point you in the right direction. It's a great attempt at the challenge!
Marked as helpful1
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