@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.
15 lines • 637 B
JavaScript
/**
* 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.
*/
export const createFetcher = (url, init, shouldReject) => async () => {
const response = await fetch(url, init);
if (shouldReject?.(response)) {
throw response;
}
return response;
};
//# sourceMappingURL=createFetcher.js.map