我使用fetch.js(https://github.com/github/fetch)将相对较大的json对象发送到后端。 json很大,它包含一个SVG图像字符串。使用fetch.js启用gzip压缩
我不清楚如果fetch.js默认使用gzip压缩,或者如果我需要手动压缩和添加标题。任何帮助,将不胜感激。
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; }); } })