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 App | HTML CSS JS API VisualStudioCode

@Enrico-Barros

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 the app doesn't work in firefox. If anyone can help me I appreciate it. (Solved!)

Community feedback

suroh 80

@m3astwood

Posted

Hi Enrico,

I had this issue in Firefox also. In your fetch request add in cache: 'no-cache' as an option. Code snippet below :

...
fetch('https://api.adviceslip.com/advice',  { cache: 'no-cache' })
...

Details can be found here

Hope this helps!

Marked as helpful

0

@Enrico-Barros

Posted

@m3astwood Thank you so much!! That also solved the loading problem between advices

0
suroh 80

@m3astwood

Posted

@Enrico-Barros my pleasure!

0

@Kamlesh0007

Posted

congratulations on completing the challenge!🎉. That's a great achievement, and I'm sure you put a lot of effort into it. I really liked the way you approached the challenge and the code you wrote. You demonstrated a good understanding of the concepts and applied them effectively to solve the problem.I have a few suggestions to improve your code further. I noticed that your app can take some time to load, and it might be a good idea to add a loader to improve the user experience. You can add a loader while fetching data from an API, you can follow these steps: add this code in ur javascript with css of loader in ur stylesheet

const loader = document.getElementById('loader');

function showLoader() {
loader.style.display = 'block';
}

function hideLoader() {
loader.style.display = 'none';
}

// Example of fetching data from an API
function GetAdvice(){
showLoader();
fetch('https://api.adviceslip.com/advice')
.then ((response) => {
return response.json();
})
.then ((json) => {
hideLoader()
const advNum = json.slip.id;
const adv = json.slip.advice;

number.innerText = advNum;
advice.innerText = adv;
})
.catch(error => {
console.log(error);
})
}

Marked as helpful

0

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