Skip to content

Commit

Permalink
refactor: path 옵셔널로 변경 (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanafromjeju committed Jan 24, 2025
1 parent 73a94f2 commit 4c6cf03
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion app/(main)/log/hooks/useLogData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { LogListResponse } from '../types'
export const useLogData = () => {
const { data, isLoading, error } = useData<LogListResponse>({
url: '/api/v1/driving-log?page=1&size=8',
path: 'result',
})
return { logData: data, isLoading, error }
}
4 changes: 2 additions & 2 deletions hooks/useData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { apiClient } from '@/lib/apis/client'
export interface UseDataProps {
url: string
params?: Record<string, string | number>
path: string
path?: string
}

export const useData = <T>({ url, params, path }: UseDataProps) => {
Expand All @@ -18,7 +18,7 @@ export const useData = <T>({ url, params, path }: UseDataProps) => {
try {
setIsLoading(true)
const response = await apiClient.get(url, { params })
setData(response.data[path])
setData(response.data.result)
} catch (error) {
setError('데이터 불러오기 실패')
console.error('Error', error)
Expand Down

0 comments on commit 4c6cf03

Please sign in to comment.