UNPKG

@kubb/plugin-client

Version:
45 lines (39 loc) 1.19 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var axios = require('axios'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var axios__default = /*#__PURE__*/_interopDefault(axios); // src/clients/axios.ts var _config = { baseURL: typeof AXIOS_BASE !== "undefined" ? AXIOS_BASE : void 0, headers: typeof AXIOS_HEADERS !== "undefined" ? JSON.parse(AXIOS_HEADERS) : void 0 }; var getConfig = () => _config; var setConfig = (config) => { _config = config; return getConfig(); }; var axiosInstance = axios__default.default.create(getConfig()); var client = async (config) => { const globalConfig = getConfig(); return axiosInstance.request({ ...globalConfig, ...config, headers: { ...globalConfig.headers, ...config.headers } }).catch((e) => { throw e; }); }; client.getConfig = getConfig; client.setConfig = setConfig; var axios_default = client; exports.axiosInstance = axiosInstance; exports.client = client; exports.default = axios_default; exports.getConfig = getConfig; exports.setConfig = setConfig; //# sourceMappingURL=axios.cjs.map //# sourceMappingURL=axios.cjs.map