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

@davdifr

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


Hope you like my solution :D That was fun!

Community feedback

Roy 600

@arkaroy135

Posted

Hello Davide, Hope you are doing well. You did a very good job in designing, but the advises are not generating when clicking the button.

const promise = fetch(url).then((response) => response.json());

the possible solution could be to use 'Let' instead of 'const' when declaring this variable.

Let promise = fetch(url, { cache: "no-store" }).then((response)=>response.json());

Use this instead. Everything else looks fine. Happy coding.

0

@davdifr

Posted

@arkaroy135 Hi, thank you for the comment but it's not like that.

As a small tip for you, since the constant that receives the promise is contained in a function there is encapsulation. This means that at the end of the function execution, the variable no longer exists.

Try pressing multiple times, the code probably runs before it has been able to receive the information from the API. The real solution would be to make the function async and make sure it only prints the information after being certain of having received the necessary information.

Happy coding!

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