react-relay-network-modern icon indicating copy to clipboard operation
react-relay-network-modern copied to clipboard

Ensure GET requests do not include a body

Open wyattjoh opened this issue 3 years ago • 1 comments

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.

wyattjoh avatar Dec 08 '21 00:12 wyattjoh

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).

wyattjoh avatar Dec 08 '21 00:12 wyattjoh