@kubb/plugin-client
Version:
API client generator plugin for Kubb, creating type-safe HTTP clients (Axios, Fetch) from OpenAPI specifications for making API requests.
33 lines (31 loc) • 871 B
JavaScript
import axios from '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.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;
export { axiosInstance, client, axios_default as default, getConfig, setConfig };
//# sourceMappingURL=axios.js.map
//# sourceMappingURL=axios.js.map