メインコンテンツまでスキップ

Fetch polyfills

Public beta for Mapbox Search JS
Mapbox Search JS はパブリック ベータ版です。パブリック ベータ段階では、フレームワークが安定するにつれて変更される可能性があります。

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 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

opts(FetchImplementation) Options for the polyfill.
NameDescription
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.

Returns

void
このsection on polyfillFetchは役に立ちましたか?
このpageは役に立ちましたか?