Skip to content

Commit 5d3b33a

Browse files
committed
fix(comment): use axios params
1 parent 4195982 commit 5d3b33a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

src/api/carts/use-carts.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ const getCarts = async ({
1515
limit = DEFAULT_LIMIT,
1616
offset = DEFAULT_OFFSET,
1717
}: Variables) => {
18-
const params = new URLSearchParams({
19-
limit: limit.toString(),
20-
offset: offset.toString(),
21-
}).toString();
22-
const { data } = await client.get(`carts?${params}`);
18+
const { data } = await client.get('carts', {
19+
params: {
20+
limit,
21+
offset,
22+
},
23+
});
2324
return { data, offset: Number(offset), limit: Number(limit) };
2425
};
2526

src/api/posts/use-post.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import type { Post } from './types';
1010
type Variables = { id: string };
1111
type Response = Post;
1212

13+
const getPosts = async (variables: Variables) => {
14+
const { data } = await client.get(`posts/${variables.id}`);
15+
return data;
16+
};
17+
1318
export const usePost = createQuery<Response, Variables, AxiosError>({
14-
// old queryKey: ['posts', 1],
15-
// ...queryFactory.posts.get(1), // this translates to ['posts', 1]
1619
...queryFactory.posts.detail(1), // this translates to ['posts', 1]
17-
fetcher: (variables) =>
18-
client.get(`posts/${variables.id}`).then((response) => response.data),
20+
fetcher: getPosts,
1921
});
2022

2123
export const usePostComments = (postId: number) =>

0 commit comments

Comments
 (0)