MCPcopy
hub / github.com/SukkaW/Surge / $$fetch

Function $$fetch

Build/lib/fetch-retry.ts:185–208  ·  view source on GitHub ↗
(url: RequestInfo, init: RequestInit = defaultRequestInit)

Source from the content-addressed store, hash-verified

183};
184
185export async function $$fetch(url: RequestInfo, init: RequestInit = defaultRequestInit) {
186 init.dispatcher = agent;
187
188 try {
189 const res = await undici.fetch(url, init);
190 if (res.status >= 400) {
191 throw new ResponseError(res, url);
192 }
193
194 if ((res.status < 200 || res.status > 299) && res.status !== 304) {
195 throw new ResponseError(res, url);
196 }
197
198 return res;
199 } catch (err: unknown) {
200 if (isAbortErrorLike(err)) {
201 console.log(picocolors.gray('[fetch abort]'), url);
202 } else {
203 console.log(picocolors.gray('[fetch fail]'), url, err);
204 }
205
206 throw err;
207 }
208}
209
210export { $$fetch as '~fetch' };
211

Calls

no outgoing calls

Tested by

no test coverage detected