fetch
fetch copied to clipboard
Use Response.json
See https://twitter.com/lcasdev/status/1564598435772342272
- https://developer.mozilla.org/en-US/docs/Web/API/Response/json_static
- https://caniuse.com/mdn-api_response_json_static
- https://github.com/WebKit/WebKit/commit/206817f17f39b6de35ea63268b74b750030d574f
Here: https://github.com/tkrotoff/fetch/blob/v0.16.0/src/createHttpError.ts#L30-L34
new Response(JSON.stringify(body), {
status,
statusText,
headers: { 'content-type': jsonMimeType }
})
becomes
Response.json(body, { status, statusText })