Description
The addition of the static Response.json(data, init)
method was refused because it isn't implemented by two major vendors. It's implemented in Blink, but not in Gecko and WebKit.
It's already implemented in Node and Deno because it's mostly useful on the backend:
-
Create easily a server response with JSON (cf. Deno v1.22):
import { serve } from "https://deno.land/[email protected]/http/server.ts"; await serve(() => Response.json({ foo: "bar" }), { port: 8080 });
-
Mock easily the response of a request:
sinon.stub(globalThis, "fetch").resolves(Response.json({ foo: "bar" }));
I think Mozilla and Apple are in no rush to implement this method. We may have this lack for a while.
I propose to add Node and Deno in the list of vendors.
Why is my fancy API still not available here?
A feature needs to be supported by two or more major browser engines or JavaScript runtime to be included here, to make sure there is a good consensus among vendors: Gecko (Firefox), Blink (Chrome/Edge), WebKit (Safari), Node and Deno.If the condition is met but still is not available here, first check the contribution guidelines below and then please file an issue.