diff --git a/docs/src/pages/guides/custom-client.md b/docs/src/pages/guides/custom-client.md index 6310e3636..582e7357a 100644 --- a/docs/src/pages/guides/custom-client.md +++ b/docs/src/pages/guides/custom-client.md @@ -36,13 +36,16 @@ export const customInstance = async ({ data?: BodyType; responseType?: string; }): Promise => { - 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(); };