Skip to content

Commit

Permalink
Merge pull request #1649 from hey-api/fix/client-nuxt-body
Browse files Browse the repository at this point in the history
fix: handle reactive refs in Nuxt client body
  • Loading branch information
mrlubos authored Jan 30, 2025
2 parents b767e10 + 603541e commit fef1f75
Show file tree
Hide file tree
Showing 20 changed files with 1,576 additions and 2,326 deletions.
5 changes: 5 additions & 0 deletions .changeset/light-fans-vanish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/client-nuxt': patch
---

fix: do not run validator and transformer when response is not ok
7 changes: 7 additions & 0 deletions .changeset/metal-flowers-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@hey-api/client-axios': patch
'@hey-api/client-fetch': patch
'@hey-api/client-nuxt': patch
---

fix: handle BigInt in JSON body serializer
5 changes: 5 additions & 0 deletions .changeset/tough-islands-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hey-api/client-nuxt': patch
---

fix: handle reactive refs in Nuxt client body
2 changes: 1 addition & 1 deletion examples/openapi-ts-axios/src/client/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import type {
UploadFileResponse,
} from './types.gen';

type Options<
export type Options<
TData extends TDataShape = TDataShape,
ThrowOnError extends boolean = boolean,
> = ClientOptions<TData, ThrowOnError> & {
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi-ts-fastify/src/client/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type {
ShowPetByIdResponse,
} from './types.gen';

type Options<
export type Options<
TData extends TDataShape = TDataShape,
ThrowOnError extends boolean = boolean,
> = ClientOptions<TData, ThrowOnError> & {
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi-ts-fetch/src/client/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import type {
UploadFileResponse,
} from './types.gen';

type Options<
export type Options<
TData extends TDataShape = TDataShape,
ThrowOnError extends boolean = boolean,
> = ClientOptions<TData, ThrowOnError> & {
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi-ts-next/src/client/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import type {
UploadFileResponse,
} from './types.gen';

type Options<
export type Options<
TData extends TDataShape = TDataShape,
ThrowOnError extends boolean = boolean,
> = ClientOptions<TData, ThrowOnError> & {
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi-ts-nuxt/client/sdk.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import {
zUploadFileResponse,
} from './zod.gen';

type Options<
export type Options<
TComposable extends Composable,
TData extends TDataShape = TDataShape,
> = ClientOptions<TComposable, TData> & {
Expand Down
72 changes: 56 additions & 16 deletions examples/openapi-ts-nuxt/components/home.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<script setup lang="ts">
import {
addPet,
findPetsByStatus,
getPetById,
type FindPetsByStatusData,
} from '~/client';
const name = ref('foo');
const petId = ref(BigInt(8));
const status =
ref<NonNullable<FindPetsByStatusData['query']>['status']>('available');
Expand All @@ -13,6 +15,10 @@ function incrementPetId() {
petId.value++;
}
function addNewPet() {
name.value = name.value === 'foo' ? 'bar' : 'foo';
}
function changeStatus() {
status.value = status.value === 'available' ? 'pending' : 'available';
}
Expand Down Expand Up @@ -79,6 +85,30 @@ const fetch = await getPetById({
},
});
await addPet({
asyncDataOptions: {
watch: [name],
},
body: {
category: {
id: BigInt(0),
name: 'Cats',
},
id: BigInt(0),
name,
photoUrls: ['string'],
status: 'available',
tags: [
{
id: BigInt(0),
name: 'pet',
},
],
},
composable: 'useAsyncData',
key: 'addPet',
});
/**
* useLazyAsyncData
*
Expand Down Expand Up @@ -121,23 +151,27 @@ watch(lazyFetch.data, (newPet) => {
});
async function handleFetch() {
const result = await getPetById({
composable: '$fetch',
onRequest: [
() => {
console.log('onRequest: local');
},
],
onResponse: [
() => {
console.log('onResponse: local');
try {
const result = await getPetById({
composable: '$fetch',
onRequest: [
() => {
console.log('onRequest: local');
},
],
onResponse: [
() => {
console.log('onResponse: local');
},
],
path: {
petId,
},
],
path: {
petId,
},
});
console.log(result);
});
console.log(result);
} catch (error) {
console.log(error);
}
}
</script>

Expand All @@ -147,5 +181,11 @@ async function handleFetch() {
<button @click="handleFetch" type="button">$fetch</button>
<button @click="incrementPetId" type="button">increment petId</button>
<button @click="changeStatus" type="button">change status</button>
<button @click="addNewPet" type="button">add pet</button>
<div>
<p>id: {{ petId }}</p>
<p>name: {{ name }}</p>
<p>status: {{ status }}</p>
</div>
</div>
</template>
7 changes: 7 additions & 0 deletions examples/openapi-ts-nuxt/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ export default defineNuxtConfig({
devtools: {
enabled: true,
},
imports: {
transform: {
// Build was throwing an error.
// see https://github.com/nuxt/nuxt/issues/18823#issuecomment-1419704343
exclude: [/\bclient-nuxt\b/],
},
},
});
3 changes: 2 additions & 1 deletion examples/openapi-ts-nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"zod": "3.23.8"
},
"devDependencies": {
"@hey-api/openapi-ts": "workspace:*"
"@hey-api/openapi-ts": "workspace:*",
"vite": "6.0.9"
}
}
5 changes: 4 additions & 1 deletion packages/client-core/src/bodySerializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export const formDataBodySerializer = {
};

export const jsonBodySerializer = {
bodySerializer: <T>(body: T) => JSON.stringify(body),
bodySerializer: <T>(body: T) =>
JSON.stringify(body, (key, value) =>
typeof value === 'bigint' ? value.toString() : value,
),
};

export const urlSearchParamsBodySerializer = {
Expand Down
3 changes: 2 additions & 1 deletion packages/client-nuxt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
},
"devDependencies": {
"@hey-api/client-core": "workspace:*",
"@nuxt/test-utils": "3.15.1"
"@nuxt/test-utils": "3.15.1",
"vite": "6.0.9"
}
}
50 changes: 23 additions & 27 deletions packages/client-nuxt/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@ import {
useLazyAsyncData,
useLazyFetch,
} from 'nuxt/app';
import { reactive, ref, watch } from 'vue';

import type { Client, Config } from './types';
import {
buildUrl,
createConfig,
executeFetchFn,
mergeConfigs,
mergeHeaders,
mergeInterceptors,
serializeBody,
setAuthParams,
unwrapRefs,
} from './utils';

export const createClient = (config: Config = {}): Client => {
Expand Down Expand Up @@ -68,6 +70,10 @@ export const createClient = (config: Config = {}): Client => {
return;
}

if (!response.ok) {
return;
}

if (responseValidator) {
await responseValidator(response._data);
}
Expand All @@ -79,10 +85,6 @@ export const createClient = (config: Config = {}): Client => {
];
}

if (opts.body && opts.bodySerializer) {
opts.body = opts.bodySerializer(unwrapRefs(opts.body));
}

// remove Content-Type header if body is empty to avoid sending invalid requests
if (!opts.body) {
opts.headers.delete('Content-Type');
Expand All @@ -91,32 +93,26 @@ export const createClient = (config: Config = {}): Client => {
const fetchFn = opts.$fetch;

if (composable === '$fetch') {
const url = buildUrl(opts);
return fetchFn(
url,
// @ts-expect-error
unwrapRefs(opts),
);
}

if (composable === 'useFetch') {
const url = buildUrl(opts);
return useFetch(url, opts);
return executeFetchFn(opts, fetchFn);
}

if (composable === 'useLazyFetch') {
const url = buildUrl(opts);
return useLazyFetch(url, opts);
if (composable === 'useFetch' || composable === 'useLazyFetch') {
const bodyParams = reactive({
body: opts.body,
bodySerializer: opts.bodySerializer,
});
const body = ref(serializeBody(opts));
opts.body = body;
watch(bodyParams, (changed) => {
body.value = serializeBody(changed);
});
return composable === 'useLazyFetch'
? useLazyFetch(() => buildUrl(opts), opts)
: useFetch(() => buildUrl(opts), opts);
}

const handler: (ctx?: NuxtApp) => Promise<any> = () => {
const url = buildUrl(opts);
return fetchFn(
url,
// @ts-expect-error
unwrapRefs(opts),
);
};
const handler: (ctx?: NuxtApp) => Promise<unknown> = () =>
executeFetchFn(opts, fetchFn);

if (composable === 'useAsyncData') {
return key
Expand Down
24 changes: 23 additions & 1 deletion packages/client-nuxt/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ type UnwrapRefs<T> =
? { [K in keyof T]: UnwrapRefs<T[K]> }
: T;

export const unwrapRefs = <T>(value: T): UnwrapRefs<T> => {
const unwrapRefs = <T>(value: T): UnwrapRefs<T> => {
if (value === null || typeof value !== 'object' || value instanceof Headers) {
return (isRef(value) ? unref(value) : value) as UnwrapRefs<T>;
}
Expand All @@ -339,3 +339,25 @@ export const unwrapRefs = <T>(value: T): UnwrapRefs<T> => {
}
return result as UnwrapRefs<T>;
};

export const serializeBody = (
opts: Pick<Parameters<Client['request']>[0], 'body' | 'bodySerializer'>,
) => {
if (opts.body && opts.bodySerializer) {
return opts.bodySerializer(opts.body);
}
return opts.body;
};

export const executeFetchFn = (
opts: Omit<Parameters<Client['request']>[0], 'composable'>,
fetchFn: Required<Config>['$fetch'],
) => {
const unwrappedOpts = unwrapRefs(opts);
unwrappedOpts.body = serializeBody(unwrappedOpts);
return fetchFn(
buildUrl(opts),
// @ts-expect-error
unwrappedOpts,
);
};
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
'use strict';var B=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var B__default=/*#__PURE__*/_interopDefault(B);var A=async(t,e)=>{let r=typeof e=="function"?await e(t):e;if(r)return t.scheme==="bearer"?`Bearer ${r}`:t.scheme==="basic"?`Basic ${btoa(r)}`:r},z=(t,e,r)=>{typeof r=="string"||r instanceof Blob?t.append(e,r):t.append(e,JSON.stringify(r));},w=(t,e,r)=>{typeof r=="string"?t.append(e,r):t.append(e,JSON.stringify(r));},j={bodySerializer:t=>{let e=new FormData;return Object.entries(t).forEach(([r,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>z(e,r,a)):z(e,r,i));}),e}},q={bodySerializer:t=>JSON.stringify(t)},P={bodySerializer:t=>{let e=new URLSearchParams;return Object.entries(t).forEach(([r,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>w(e,r,a)):w(e,r,i));}),e}},v=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},$=t=>{switch(t){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},k=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},h=({allowReserved:t,explode:e,name:r,style:i,value:a})=>{if(!e){let n=(t?a:a.map(o=>encodeURIComponent(o))).join($(i));switch(i){case "label":return `.${n}`;case "matrix":return `;${r}=${n}`;case "simple":return n;default:return `${r}=${n}`}}let s=v(i),l=a.map(n=>i==="label"||i==="simple"?t?n:encodeURIComponent(n):f({allowReserved:t,name:r,value:n})).join(s);return i==="label"||i==="matrix"?s+l:l},f=({allowReserved:t,name:e,value:r})=>{if(r==null)return "";if(typeof r=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${e}=${t?r:encodeURIComponent(r)}`},g=({allowReserved:t,explode:e,name:r,style:i,value:a})=>{if(a instanceof Date)return `${r}=${a.toISOString()}`;if(i!=="deepObject"&&!e){let n=[];Object.entries(a).forEach(([u,d])=>{n=[...n,u,t?d:encodeURIComponent(d)];});let o=n.join(",");switch(i){case "form":return `${r}=${o}`;case "label":return `.${o}`;case "matrix":return `;${r}=${o}`;default:return o}}let s=k(i),l=Object.entries(a).map(([n,o])=>f({allowReserved:t,name:i==="deepObject"?`${r}[${n}]`:n,value:o})).join(s);return i==="label"||i==="matrix"?s+l:l};var E=/\{[^{}]+\}/g,T=({path:t,url:e})=>{let r=e,i=e.match(E);if(i)for(let a of i){let s=false,l=a.substring(1,a.length-1),n="simple";l.endsWith("*")&&(s=true,l=l.substring(0,l.length-1)),l.startsWith(".")?(l=l.substring(1),n="label"):l.startsWith(";")&&(l=l.substring(1),n="matrix");let o=t[l];if(o==null)continue;if(Array.isArray(o)){r=r.replace(a,h({explode:s,name:l,style:n,value:o}));continue}if(typeof o=="object"){r=r.replace(a,g({explode:s,name:l,style:n,value:o}));continue}if(n==="matrix"){r=r.replace(a,`;${f({name:l,value:o})}`);continue}let u=encodeURIComponent(n==="label"?`.${o}`:o);r=r.replace(a,u);}return r},U=({allowReserved:t,array:e,object:r}={})=>a=>{let s=[];if(a&&typeof a=="object")for(let l in a){let n=a[l];if(n!=null){if(Array.isArray(n)){s=[...s,h({allowReserved:t,explode:true,name:l,style:"form",value:n,...e})];continue}if(typeof n=="object"){s=[...s,g({allowReserved:t,explode:true,name:l,style:"deepObject",value:n,...r})];continue}s=[...s,f({allowReserved:t,name:l,value:n})];}}return s.join("&")},R=async({security:t,...e})=>{for(let r of t){let i=await A(r,e.auth);if(!i)continue;let a=r.name??"Authorization";switch(r.in){case "query":e.query||(e.query={}),e.query[a]=i;break;case "header":default:e.headers[a]=i;break}return}},b=t=>D({path:t.path,query:t.paramsSerializer?undefined:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:U(t.querySerializer),url:t.url}),D=({path:t,query:e,querySerializer:r,url:i})=>{let s=i.startsWith("/")?i:`/${i}`;t&&(s=T({path:t,url:s}));let l=e?r(e):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(s+=`?${l}`),s},S=(t,e)=>{let r={...t,...e};return r.headers=y(t.headers,e.headers),r},H=["common","delete","get","head","patch","post","put"],y=(...t)=>{let e={};for(let r of t){if(!r||typeof r!="object")continue;let i=Object.entries(r);for(let[a,s]of i)if(H.includes(a)&&typeof s=="object")e[a]={...e[a],...s};else if(s===null)delete e[a];else if(Array.isArray(s))for(let l of s)e[a]=[...e[a]??[],l];else s!==undefined&&(e[a]=typeof s=="object"?JSON.stringify(s):s);}return e},x=(t={})=>({baseURL:"",...t});var I=(t={})=>{let e=S(x(),t),{auth:r,...i}=e,a=B__default.default.create(i),s=()=>({...e}),l=o=>(e=S(e,o),a.defaults={...a.defaults,...e,headers:y(a.defaults.headers,e.headers)},s()),n=async o=>{let u={...e,...o,axios:o.axios??e.axios??a,headers:y(e.headers,o.headers)};u.security&&await R({...u,security:u.security}),u.body&&u.bodySerializer&&(u.body=u.bodySerializer(u.body));let d=b(u);try{let m=u.axios,{auth:c,...O}=u,C=await m({...O,data:u.body,headers:u.headers,params:u.paramsSerializer?u.query:void 0,url:d}),{data:p}=C;return u.responseType==="json"&&(u.responseValidator&&await u.responseValidator(p),u.responseTransformer&&(p=await u.responseTransformer(p))),{...C,data:p??{}}}catch(m){let c=m;if(u.throwOnError)throw c;return c.error=c.response?.data??{},c}};return {buildUrl:b,delete:o=>n({...o,method:"DELETE"}),get:o=>n({...o,method:"GET"}),getConfig:s,head:o=>n({...o,method:"HEAD"}),instance:a,options:o=>n({...o,method:"OPTIONS"}),patch:o=>n({...o,method:"PATCH"}),post:o=>n({...o,method:"POST"}),put:o=>n({...o,method:"PUT"}),request:n,setConfig:l}};exports.createClient=I;exports.createConfig=x;exports.formDataBodySerializer=j;exports.jsonBodySerializer=q;exports.urlSearchParamsBodySerializer=P;//# sourceMappingURL=index.cjs.map
'use strict';var B=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var B__default=/*#__PURE__*/_interopDefault(B);var A=async(t,r)=>{let e=typeof r=="function"?await r(t):r;if(e)return t.scheme==="bearer"?`Bearer ${e}`:t.scheme==="basic"?`Basic ${btoa(e)}`:e},z=(t,r,e)=>{typeof e=="string"||e instanceof Blob?t.append(r,e):t.append(r,JSON.stringify(e));},w=(t,r,e)=>{typeof e=="string"?t.append(r,e):t.append(r,JSON.stringify(e));},j={bodySerializer:t=>{let r=new FormData;return Object.entries(t).forEach(([e,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>z(r,e,a)):z(r,e,i));}),r}},q={bodySerializer:t=>JSON.stringify(t,(r,e)=>typeof e=="bigint"?e.toString():e)},P={bodySerializer:t=>{let r=new URLSearchParams;return Object.entries(t).forEach(([e,i])=>{i!=null&&(Array.isArray(i)?i.forEach(a=>w(r,e,a)):w(r,e,i));}),r}},v=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},$=t=>{switch(t){case "form":return ",";case "pipeDelimited":return "|";case "spaceDelimited":return "%20";default:return ","}},k=t=>{switch(t){case "label":return ".";case "matrix":return ";";case "simple":return ",";default:return "&"}},h=({allowReserved:t,explode:r,name:e,style:i,value:a})=>{if(!r){let n=(t?a:a.map(o=>encodeURIComponent(o))).join($(i));switch(i){case "label":return `.${n}`;case "matrix":return `;${e}=${n}`;case "simple":return n;default:return `${e}=${n}`}}let s=v(i),l=a.map(n=>i==="label"||i==="simple"?t?n:encodeURIComponent(n):f({allowReserved:t,name:e,value:n})).join(s);return i==="label"||i==="matrix"?s+l:l},f=({allowReserved:t,name:r,value:e})=>{if(e==null)return "";if(typeof e=="object")throw new Error("Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these.");return `${r}=${t?e:encodeURIComponent(e)}`},g=({allowReserved:t,explode:r,name:e,style:i,value:a})=>{if(a instanceof Date)return `${e}=${a.toISOString()}`;if(i!=="deepObject"&&!r){let n=[];Object.entries(a).forEach(([u,d])=>{n=[...n,u,t?d:encodeURIComponent(d)];});let o=n.join(",");switch(i){case "form":return `${e}=${o}`;case "label":return `.${o}`;case "matrix":return `;${e}=${o}`;default:return o}}let s=k(i),l=Object.entries(a).map(([n,o])=>f({allowReserved:t,name:i==="deepObject"?`${e}[${n}]`:n,value:o})).join(s);return i==="label"||i==="matrix"?s+l:l};var E=/\{[^{}]+\}/g,T=({path:t,url:r})=>{let e=r,i=r.match(E);if(i)for(let a of i){let s=false,l=a.substring(1,a.length-1),n="simple";l.endsWith("*")&&(s=true,l=l.substring(0,l.length-1)),l.startsWith(".")?(l=l.substring(1),n="label"):l.startsWith(";")&&(l=l.substring(1),n="matrix");let o=t[l];if(o==null)continue;if(Array.isArray(o)){e=e.replace(a,h({explode:s,name:l,style:n,value:o}));continue}if(typeof o=="object"){e=e.replace(a,g({explode:s,name:l,style:n,value:o}));continue}if(n==="matrix"){e=e.replace(a,`;${f({name:l,value:o})}`);continue}let u=encodeURIComponent(n==="label"?`.${o}`:o);e=e.replace(a,u);}return e},U=({allowReserved:t,array:r,object:e}={})=>a=>{let s=[];if(a&&typeof a=="object")for(let l in a){let n=a[l];if(n!=null){if(Array.isArray(n)){s=[...s,h({allowReserved:t,explode:true,name:l,style:"form",value:n,...r})];continue}if(typeof n=="object"){s=[...s,g({allowReserved:t,explode:true,name:l,style:"deepObject",value:n,...e})];continue}s=[...s,f({allowReserved:t,name:l,value:n})];}}return s.join("&")},R=async({security:t,...r})=>{for(let e of t){let i=await A(e,r.auth);if(!i)continue;let a=e.name??"Authorization";switch(e.in){case "query":r.query||(r.query={}),r.query[a]=i;break;case "header":default:r.headers[a]=i;break}return}},b=t=>D({path:t.path,query:t.paramsSerializer?undefined:t.query,querySerializer:typeof t.querySerializer=="function"?t.querySerializer:U(t.querySerializer),url:t.url}),D=({path:t,query:r,querySerializer:e,url:i})=>{let s=i.startsWith("/")?i:`/${i}`;t&&(s=T({path:t,url:s}));let l=r?e(r):"";return l.startsWith("?")&&(l=l.substring(1)),l&&(s+=`?${l}`),s},S=(t,r)=>{let e={...t,...r};return e.headers=y(t.headers,r.headers),e},H=["common","delete","get","head","patch","post","put"],y=(...t)=>{let r={};for(let e of t){if(!e||typeof e!="object")continue;let i=Object.entries(e);for(let[a,s]of i)if(H.includes(a)&&typeof s=="object")r[a]={...r[a],...s};else if(s===null)delete r[a];else if(Array.isArray(s))for(let l of s)r[a]=[...r[a]??[],l];else s!==undefined&&(r[a]=typeof s=="object"?JSON.stringify(s):s);}return r},x=(t={})=>({baseURL:"",...t});var I=(t={})=>{let r=S(x(),t),{auth:e,...i}=r,a=B__default.default.create(i),s=()=>({...r}),l=o=>(r=S(r,o),a.defaults={...a.defaults,...r,headers:y(a.defaults.headers,r.headers)},s()),n=async o=>{let u={...r,...o,axios:o.axios??r.axios??a,headers:y(r.headers,o.headers)};u.security&&await R({...u,security:u.security}),u.body&&u.bodySerializer&&(u.body=u.bodySerializer(u.body));let d=b(u);try{let m=u.axios,{auth:c,...O}=u,C=await m({...O,data:u.body,headers:u.headers,params:u.paramsSerializer?u.query:void 0,url:d}),{data:p}=C;return u.responseType==="json"&&(u.responseValidator&&await u.responseValidator(p),u.responseTransformer&&(p=await u.responseTransformer(p))),{...C,data:p??{}}}catch(m){let c=m;if(u.throwOnError)throw c;return c.error=c.response?.data??{},c}};return {buildUrl:b,delete:o=>n({...o,method:"DELETE"}),get:o=>n({...o,method:"GET"}),getConfig:s,head:o=>n({...o,method:"HEAD"}),instance:a,options:o=>n({...o,method:"OPTIONS"}),patch:o=>n({...o,method:"PATCH"}),post:o=>n({...o,method:"POST"}),put:o=>n({...o,method:"PUT"}),request:n,setConfig:l}};exports.createClient=I;exports.createConfig=x;exports.formDataBodySerializer=j;exports.jsonBodySerializer=q;exports.urlSearchParamsBodySerializer=P;//# sourceMappingURL=index.cjs.map
//# sourceMappingURL=index.cjs.map
Loading

0 comments on commit fef1f75

Please sign in to comment.