Skip to content
Advertisement

How do I use a fetch get response more than once?

I want to set both of these values in the state to be used later as variables.

JavaScript

But it gives the error:

JavaScript

How do I fix this?

Advertisement

Answer

Try this:

JavaScript

The last two .then statements need to be combined. By calling .then twice, you’re sending the result of setDollarValue() (a void function) to the next .then, which is not what you want.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement