@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.
@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!