Description
When creating a Response or Request with a plain JS object body, it is automatically serialized to JSON and the Content-Type header is set to application/json. However, this does not work for arrays, which are also valid JSON values.
Expected behavior
const res = new Response([1, 2, 3]);
// Content-Type: application/json
// body: [1,2,3]
Actual behavior
Arrays fall through to guessContentType, which does not recognize them as JSON, so no Content-Type is set and the body is not serialized.
Fix
The isPlainObject check in response.js (and request.js) should be extended to also handle arrays (Array.isArray(body)).
Description
When creating a
ResponseorRequestwith a plain JS object body, it is automatically serialized to JSON and theContent-Typeheader is set toapplication/json. However, this does not work for arrays, which are also valid JSON values.Expected behavior
Actual behavior
Arrays fall through to
guessContentType, which does not recognize them as JSON, so noContent-Typeis set and the body is not serialized.Fix
The
isPlainObjectcheck inresponse.js(andrequest.js) should be extended to also handle arrays (Array.isArray(body)).