All files / Cognigy-CLI/build/utils axiosClient.js

0% Statements 0/15
0% Branches 0/13
0% Functions 0/2
0% Lines 0/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                                                 
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeAxiosRequest = void 0;
const axios_1 = __importDefault(require("axios"));
const config_1 = __importDefault(require("./config"));
axios_1.default.defaults.headers.common = {
    'X-API-Key': config_1.default.apiKey,
};
const makeAxiosRequest = async (options) => {
    const { method, path, data, form, type } = options;
    const url = config_1.default.baseUrl + path;
    const axiosOptions = {
        headers: {
            Accept: type || 'application/json',
            'Content-Type': 'application/json',
            'Cache-Control': 'no-cache',
        },
        method,
        url,
        maxContentLength: Infinity,
        maxBodyLength: Infinity,
        data: form || data,
    };
    if (form) {
        axiosOptions.headers = Object.assign({}, axiosOptions.headers, form.getHeaders());
    }
    return await (0, axios_1.default)(axiosOptions);
};
exports.makeAxiosRequest = makeAxiosRequest;