File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed
Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change @@ -10,12 +10,14 @@ import type { Post } from './types';
1010type Variables = { id : string } ;
1111type Response = Post ;
1212
13+ const getPosts = async ( variables : Variables ) => {
14+ const { data } = await client . get ( `posts/${ variables . id } ` ) ;
15+ return data ;
16+ } ;
17+
1318export 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
2123export const usePostComments = ( postId : number ) =>
You can’t perform that action at this time.
0 commit comments