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

Function request

scripts/stress/simdeck.mjs:169–189  ·  view source on GitHub ↗
(method, path, body)

Source from the content-addressed store, hash-verified

167}
168
169async function request(method, path, body) {
170 const response = await fetch(`${serverUrl}${path}`, {
171 method,
172 headers: body ? { "content-type": "application/json" } : undefined,
173 body: body ? JSON.stringify(body) : undefined,
174 });
175 const text = await response.text();
176 if (!response.ok) {
177 throw new Error(
178 `${method} ${path} failed with ${response.status}: ${text.slice(0, 500)}`,
179 );
180 }
181 if (!text) {
182 return null;
183 }
184 try {
185 return JSON.parse(text);
186 } catch {
187 return text;
188 }
189}
190
191function sampleRss(label) {
192 if (!pid) {

Callers 3

requestWithTimeoutFunction · 0.85
runIterationFunction · 0.85
assertHealthyFunction · 0.85

Calls 3

fetchFunction · 0.85
textMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected