I have an extremely large JSON string that I need to send to my server. I encountered payloadTooLargeError
when I tried sending the JSON string directly.
So, I decided to send it as a blob instead. But unfortunately, after creating the blob, the blob is returning an empty string.
Here is how I created the blob:
let largeContentPayload = {
data: {
'batch_id': batchId,
content: extremelyLargeJSON
}
};
const largeContentStringified = JSON.stringify(largeContentPayload);
const largeContentBlob = new Blob([largeContentStringified], {
type: 'application/json;charset=utf-8'
});
console.log(largeContentBlob); //This is only returning size and type, the JSON string is not there
const blobUrl = URL.createObjectURL(largeContentBlob);
let requestBody = new FormData();
let blob = await fetch(blobUrl).then(r => r.blob());
How can this be resolved?