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 committed Oct 19, 2024
1 parent 87e1db6 commit 447f33f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/src/pages/guides/custom-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ export const customInstance = async <T>({
data?: BodyType<unknown>;
responseType?: string;
}): Promise<T> => {
let targetUrl = `${baseURL}${url}`

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

const response = await fetch(
`${baseURL}${url}` + new URLSearchParams(params),
targetUrl,
{
method,
...(data ? { body: JSON.stringify(data) } : {}),
Expand Down

0 comments on commit 447f33f

Please sign in to comment.