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 844 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleRequest = void 0; 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 }); }; exports.handleRequest = handleRequest; //# sourceMappingURL=RequestHandlers.js.map