Skip to content

Commit 14c36fa

Browse files
authored
Fix custom client example to include a ? before query parameters (#1667)
1 parent 87e1db6 commit 14c36fa

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

docs/src/pages/guides/custom-client.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ export const customInstance = async <T>({
3636
data?: BodyType<unknown>;
3737
responseType?: string;
3838
}): Promise<T> => {
39-
const response = await fetch(
40-
`${baseURL}${url}` + new URLSearchParams(params),
41-
{
42-
method,
43-
...(data ? { body: JSON.stringify(data) } : {}),
44-
},
45-
);
39+
let targetUrl = `${baseURL}${url}`;
40+
41+
if (params) {
42+
targetUrl += '?' + new URLSearchParams(params);
43+
}
44+
45+
const response = await fetch(targetUrl, {
46+
method,
47+
...(data ? { body: JSON.stringify(data) } : {}),
48+
});
4649

4750
return response.json();
4851
};

0 commit comments

Comments
 (0)