UNPKG

@coveo/platform-client

Version:

The main goal of this package is to provide an easy to configure and straightforward way of querying Coveo Cloud APIs using JavaScript.

19 lines 778 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createFetcher = void 0; /** * Creates a method to perform a fetch request. Can be retried by calling the method again. * @param url The URL to use for the request. * @param init The parameters to provide to the request. * @param shouldReject Predicate to see if the response should be (Promise) rejected. * @returns A method, taking no arguments, that may be called multiple times to repeat the request. */ const createFetcher = (url, init, shouldReject) => async () => { const response = await fetch(url, init); if (shouldReject?.(response)) { throw response; } return response; }; exports.createFetcher = createFetcher; //# sourceMappingURL=createFetcher.js.map