UNPKG

@kubb/plugin-client

Version:

API client generator plugin for Kubb, creating type-safe HTTP clients (Axios, Fetch) from OpenAPI specifications for making API requests.

40 lines (38 loc) 1.09 kB
Object.defineProperty(exports, '__esModule', { value: true }); const require_chunk = require('../chunk-CbDLau6x.cjs'); let axios = require("axios"); axios = require_chunk.__toESM(axios); //#region src/clients/axios.ts let _config = { baseURL: typeof AXIOS_BASE !== "undefined" ? AXIOS_BASE : void 0, headers: typeof AXIOS_HEADERS !== "undefined" ? JSON.parse(AXIOS_HEADERS) : void 0 }; const getConfig = () => _config; const setConfig = (config) => { _config = config; return getConfig(); }; const axiosInstance = axios.default.create(getConfig()); const 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; //#endregion exports.axiosInstance = axiosInstance; exports.client = client; exports.default = axios_default; exports.getConfig = getConfig; exports.setConfig = setConfig; //# sourceMappingURL=axios.cjs.map