22 lines
495 B
TypeScript
22 lines
495 B
TypeScript
|
|
interface ReqApiData {
|
|
baseApiUrl: string
|
|
url: string
|
|
}
|
|
|
|
export const useApiData = async (req: ReqApiData): Promise<any> => {
|
|
const dataUrl = `${req.baseApiUrl}/${req.url}` // 정상 URL 경로
|
|
try {
|
|
const fetch = await $fetch<any>(dataUrl, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
}
|
|
})
|
|
return fetch
|
|
} catch (error) {
|
|
console.log('error', error)
|
|
return []
|
|
}
|
|
}
|
|
|