I am utilizing fetch.js (https://github.com/github/fetch) to transmit a rather substantial JSON object to the backend. The size of the JSON is significant due to it containing an SVG image string.
My question is whether fetch.js applies gzip compression automatically, or if I need to manually compress and include headers?
return new Promise((resolve, reject) => {
fetch(api_base + "/api/save-photo", {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
})
.then((response) => {
if (response.status === 404) {
throw new Error('404 (Not Found)');
} else {
return response.json().then((json) => {
console.log('save poster response: ', json);
return json;
});
}
});
});