MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / fetchJson

Function fetchJson

scripts/studio-provider-bridge.mjs:646–667  ·  view source on GitHub ↗
(url, body)

Source from the content-addressed store, hash-verified

644}
645
646async function fetchJson(url, body) {
647 let response;
648 try {
649 response = await fetch(url, {
650 body: JSON.stringify(body),
651 headers: { "content-type": "application/json" },
652 method: "POST",
653 signal: AbortSignal.timeout(cloudRequestTimeoutMs),
654 });
655 } catch (error) {
656 throw new Error(`Studio request ${url} failed`, { cause: error });
657 }
658 if (response.status === 204) {
659 return null;
660 }
661 if (!response.ok) {
662 throw new Error(
663 `${url} failed with ${response.status}: ${await response.text()}`,
664 );
665 }
666 return response.json();
667}
668
669function sleep(ms) {
670 return new Promise((resolve) => setTimeout(resolve, ms));

Callers 5

registerProviderFunction · 0.70
markProviderStatusFunction · 0.70
completeFunction · 0.70

Calls 3

fetchFunction · 0.85
jsonMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected