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.

15 lines 703 B
export const handleRequest = (url, requestInit, requestHandlers) => { if (!requestHandlers || !requestHandlers?.length) { return { ...requestInit, url }; } return requestHandlers.reduce((enrichedOptions, currentHandler) => { if (!Object.prototype.hasOwnProperty.call(currentHandler, 'canProcess') || !Object.prototype.hasOwnProperty.call(currentHandler, 'process')) { return enrichedOptions; } return currentHandler.canProcess(enrichedOptions) ? { ...enrichedOptions, ...currentHandler.process(enrichedOptions) } : enrichedOptions; }, { ...requestInit, url }); }; //# sourceMappingURL=RequestHandlers.js.map