ava / use-http

🐶 React hook for making isomorphic http requests
https://use-http.com
MIT License
2.32k stars 114 forks source link

`Response` is not defined in Node #265

Open thure opened 4 years ago

thure commented 4 years ago

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:

  1. Create a React component that uses useFetch
  2. Add the following to its render function:
    const {response} = useFetch('https://localhost:4001')
    const responseStatus = response.status
  3. Render using Node

Expected behavior The getter for responses should return the right value whether on the server or on the client.

alex-cory commented 4 years ago

I will take a look as soon as possible! Bare with me!

piersolenski commented 3 years ago

Any movement on this? 🙏

hashinteractive commented 3 years ago

Experiencing the same issue with Gatsby static build render (on server).

Are there any updates on this by chance?

piersolenski commented 3 years ago

Ended up switching to https://react-query.tanstack.com/ - would recommend it!

hashinteractive commented 3 years ago

@piersolenski thanks for the reference!

alex-cory commented 3 years ago

Sorry for the delay guys. I'm extremely busy and haven't had time to debug this. A PR is very much welcomed.

pachkovska commented 2 years ago

I am getting same error after upgrading Gatsby from 2 to 4.