Design comparison
Solution retrospective
Hope you like my solution :D That was fun!
Community feedback
- @arkaroy135Posted almost 2 years ago
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@davdifrPosted almost 2 years ago@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 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