Skip to content

Commit

Permalink
feat: getCategory query 등록 (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinhyojeong authored Dec 13, 2023
2 parents 3556ee1 + f5a51f5 commit dea63ce
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/apis/post/apis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { GetCategoriesRes } from './types'
import { http } from '@utils/http'

export const getCategories = () =>
http.get<null, GetCategoriesRes>('/categories')
2 changes: 2 additions & 0 deletions src/apis/post/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './types'
export * from './queries'
8 changes: 8 additions & 0 deletions src/apis/post/queries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useQuery } from '@tanstack/react-query'
import { getCategories } from './apis'

export const useGetCategoriesQuery = () =>
useQuery({
queryKey: ['getCategories'],
queryFn: getCategories
})
4 changes: 4 additions & 0 deletions src/apis/post/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type GetCategoriesRes = {
code: string
name: string
}[]

0 comments on commit dea63ce

Please sign in to comment.