UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

15 lines 845 B
import { __awaiter } from "tslib"; export const GenericAPIFn = (url, method, _this) => { return (data, options = {}) => __awaiter(void 0, void 0, void 0, function* () { var _a; options.withAuthentication = (_a = options.withAuthentication) !== null && _a !== void 0 ? _a : true; const httpAdapter = _this.getHttpAdapter(); const payload = Object.assign(Object.assign({}, options), { headers: Object.assign({ Accept: "application/json", "Content-Type": "application/json", "Cache-Control": "no-cache" }, options === null || options === void 0 ? void 0 : options.headers), method, url, data }); const response = yield httpAdapter.request(payload, _this); const responseData = response.data; return responseData; }); }; //# sourceMappingURL=GenericAPIFn.js.map