use-http
use-http copied to clipboard
`Response` is not defined in Node
Describe the bug
useFetch crashes the SSR server if the code makes any call to the getter for a response. The getter uses instanceof Response, expecting Reponse on the global namespace, which is undefined in Node.
To Reproduce Steps to reproduce the behavior:
- Create a React component that uses
useFetch - Add the following to its render function:
const {response} = useFetch('https://localhost:4001')
const responseStatus = response.status
- Render using Node
Expected behavior The getter for responses should return the right value whether on the server or on the client.
I will take a look as soon as possible! Bare with me!
Any movement on this? 🙏
Experiencing the same issue with Gatsby static build render (on server).
Are there any updates on this by chance?
Ended up switching to https://react-query.tanstack.com/ - would recommend it!
@piersolenski thanks for the reference!
Sorry for the delay guys. I'm extremely busy and haven't had time to debug this. A PR is very much welcomed.
I am getting same error after upgrading Gatsby from 2 to 4.