MCPcopy Create free account
hub / github.com/nodejs/node / json

Method json

deps/undici/undici.js:12026–12038  ·  view source on GitHub ↗
(data, init = void 0)

Source from the content-addressed store, hash-verified

12024 }
12025 // https://fetch.spec.whatwg.org/#dom-response-json
12026 static json(data, init = void 0) {
12027 webidl.argumentLengthCheck(arguments, 1, "Response.json");
12028 if (init !== null) {
12029 init = webidl.converters.ResponseInit(init);
12030 }
12031 const bytes = textEncoder.encode(
12032 serializeJavascriptValueToJSONString(data)
12033 );
12034 const body = extractBody(bytes);
12035 const responseObject = fromInnerResponse(makeResponse({}), "response");
12036 initializeResponse(responseObject, init, { body: body[0], type: "application/json" });
12037 return responseObject;
12038 }
12039 // Creates a redirect Response that redirects to url with status status.
12040 static redirect(url, status = 302) {
12041 webidl.argumentLengthCheck(arguments, 1, "Response.redirect");

Callers

nothing calls this directly

Calls 7

argumentLengthCheckMethod · 0.80
encodeMethod · 0.80
extractBodyFunction · 0.70
fromInnerResponseFunction · 0.70
makeResponseFunction · 0.70
initializeResponseFunction · 0.70

Tested by

no test coverage detected