Skip to content

Commit

Permalink
Fix custom client example to include a ? before query parameters (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dob9601 authored Oct 19, 2024
1 parent 87e1db6 commit 14c36fa
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions docs/src/pages/guides/custom-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,16 @@ export const customInstance = async <T>({
data?: BodyType<unknown>;
responseType?: string;
}): Promise<T> => {
const response = await fetch(
`${baseURL}${url}` + new URLSearchParams(params),
{
method,
...(data ? { body: JSON.stringify(data) } : {}),
},
);
let targetUrl = `${baseURL}${url}`;

if (params) {
targetUrl += '?' + new URLSearchParams(params);
}

const response = await fetch(targetUrl, {
method,
...(data ? { body: JSON.stringify(data) } : {}),
});

return response.json();
};
Expand Down

0 comments on commit 14c36fa

Please sign in to comment.