MCPcopy Index your code
hub / github.com/RustPython/RustPython / genericFetch

Function genericFetch

wasm/notebook/src/tools.js:11–24  ·  view source on GitHub ↗
(path, fetchType)

Source from the content-addressed store, hash-verified

9};
10
11export function genericFetch(path, fetchType) {
12 const responseType = getResponseTypeFromFetchType(fetchType);
13 return fetch(path)
14 .then((r) => {
15 if (!r.ok) throw new Error(`${r.status} ${r.statusText} (${path})`);
16 return r[responseType]();
17 })
18 .then((r) => {
19 if (fetchType === 'bytes') {
20 return new Uint8Array(r);
21 }
22 return r;
23 });
24}

Callers 1

index.jsFile · 0.90

Calls 3

fetchFunction · 0.85
thenMethod · 0.45

Tested by

no test coverage detected