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.
Polyfills fetch 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.
| Name | Description |
|---|---|
| opts FetchImplementation | Options for the polyfill. |
| opts.AbortController AbortController | Required. A custom
AbortController
implementation.
|
| opts.fetch fetch | Required. A custom
fetch
implementation.
|
force boolean (default false) | If
true
, the polyfill will be forced to load. Otherwise, it will only load if
fetch
is not available.
|