react-relay-network-modern
react-relay-network-modern copied to clipboard
Ensure GET requests do not include a body
When a middleware changes the req.fetchOpts.method to GET, at the moment, it will try to send the body parameter down to fetch which causes an error:
TypeError: Window.fetch: HEAD or GET Request cannot have a body.
This change ensures that requests sent as GET will not include the body.
Note that this further only sends down the parameters used by fetch, noteably not the url. It also ensures that the Content-Type header is not set on the upstream object, and is only sent to fetch if the body is being sent (it is a POST request and not form data).