UNPKG

foca-openapi

Version:

根据openapi文档生成请求客户端

25 lines 859 B
// src/adapters/axios.ts var axiosAdapter = (axios, returningData = (response) => response.data) => { return { async request(opts, utils) { const body = utils.formatBody(opts.requestBodyType, opts.body); const credentials = opts.credentials === "omit" || opts.credentials === false ? false : typeof opts.credentials === "string" || opts.credentials === true ? true : void 0; const config = { url: opts.uri, method: opts.method, params: opts.query, data: body, headers: opts.headers, timeout: opts.timeout, withCredentials: credentials, responseType: opts.responseType }; const result = await axios.request(opts.onBeforeRequest?.(config) || config); return returningData(result); } }; }; export { axiosAdapter }; //# sourceMappingURL=axios.js.map