Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Advice generator. #2 Challenge

zer0VAns 30

@zer0VAns

Desktop design screenshot for the Advice generator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


For some reason it only works one time. I was looking for a solution but i didn't find it

Community feedback

Elaine 11,420

@elaineleung

Posted

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 using no-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 helpful

1

zer0VAns 30

@zer0VAns

Posted

@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
P
Cassidy 555

@Darknessflowers

Posted

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 helpful

1

Please log in to post a comment

Log in with GitHub
Discord logo

Join 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