> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/mapbox-search-js/llms.txt)

# Fetch polyfills

When running Search JS Core in a Node.js environment, the global fetch implementation must be polyfilled.

This can be done either through a global polyfill (for example, `import 'cross-fetch/polyfill';`) or by passing in a fetch object directly into the polyfillFetch function below. We recommend using well-supported libraries like `cross-fetch` or `node-fetch`.

### polyfillFetch

Polyfills [fetch](https://developer.mozilla.org/docs/Web/API/Fetch_API) implementation used in Search JS Core.

If a `fetch` implementation is already available, the polyfill will be silently ignored.

When running Search JS Core in a Node.js environment, fetch must be either polyfilled globally or passed into this function before usage of internal library functionality.

#### Parameters

| Name | Description |
| --- | --- |
| **opts** FetchImplementation  | Options for the polyfill. |
| **opts.AbortController** AbortController  | Required. A custom `AbortController` implementation. |
| **opts.fetch** [fetch](https://developer.mozilla.org/docs/Web/API/Fetch_API)  | Required. A custom `fetch` implementation. |
| **force** [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean) (default `false`) | If `true` , the polyfill will be forced to load. Otherwise, it will only load if `fetch` is not available. |

#### Returns

void

Was this section on polyfillFetch helpful?[Yes](null)[No](null)