MCPcopy Create free account
hub / github.com/developit/unfetch / response

Function response

src/index.mjs:8–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6 const headers = {};
7
8 const response = () => ({
9 ok: ((request.status / 100) | 0) == 2, // 200-299
10 statusText: request.statusText,
11 status: request.status,
12 url: request.responseURL,
13 text: () => Promise.resolve(request.responseText),
14 json: () => Promise.resolve(request.responseText).then(JSON.parse),
15 blob: () => Promise.resolve(new Blob([request.response])),
16 clone: response,
17 headers: {
18 keys: () => keys,
19 entries: () => keys.map((n) => [n, request.getResponseHeader(n)]),
20 get: (n) => request.getResponseHeader(n),
21 has: (n) => request.getResponseHeader(n) != null,
22 },
23 });
24
25 request.open(options.method || "get", url, true);
26

Callers 1

index.mjsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…