MCPcopy Create free account
hub / github.com/apify/impit / fetch

Method fetch

impit-node/index.wrapper.js:262–281  ·  view source on GitHub ↗
(resource, init)

Source from the content-addressed store, hash-verified

260 }
261
262 async fetch(resource, init) {
263 const { url: initialUrl, signal, redirect, ...options } = await this.#parseFetchOptions(resource, init);
264
265 // Check immediately if already aborted (before creating any promises)
266 signal?.throwIfAborted();
267
268 let abortHandler;
269 const waitForAbort = new Promise((_, reject) => {
270 abortHandler = () => reject(signal.reason);
271 signal?.addEventListener?.("abort", abortHandler, { once: true });
272 });
273
274 try {
275 return await this.#fetchWithRedirectHandling(initialUrl, options, signal, waitForAbort, redirect);
276 } catch (err) {
277 rethrowNativeError(err);
278 } finally {
279 signal?.removeEventListener?.("abort", abortHandler);
280 }
281 }
282
283 /**
284 * Fetch with manual redirect handling

Callers 1

Calls 3

#parseFetchOptionsMethod · 0.95
rethrowNativeErrorFunction · 0.85

Tested by

no test coverage detected