I have a fetch
POST
that is sending a large JSON object:
const body = JSON.stringify(largeItem); // 80MB
const request = new Request(uri, {
mode: 'cors',
method: 'POST',
headers: new Headers({ 'Content-Type': 'application/json' }),
credentials: 'same-origin',
body
});
const response = await fetch(request);
This results in an error:
source-file.ts:72 Uncaught (in promise) TypeError: Failed to fetch
When I view this request in dev tools it looks incomplete - no request body and most of the request headers are missing. In addition it errors without a status code, instead the status is:
(failed) net::ERR_CONNECTION_RESET
Lots of other GET
and POST
requests to the same resource with the same credentials work fine. This code works fine with a smaller body
.
How do I POST
a request with a large (in this case 80MB) JSON body?