2023-05-22 18:11:31 -07:00
|
|
|
import { ofetch } from 'ofetch'
|
|
|
|
|
import { handleError } from '@/store/state.js'
|
|
|
|
|
|
|
|
|
|
export const useFetch = async (url, item) => {
|
|
|
|
|
try {
|
|
|
|
|
return await ofetch(url)
|
|
|
|
|
} catch (err) {
|
|
|
|
|
handleError({ message: `Error fetching ${item}` })
|
2023-06-02 07:09:46 -07:00
|
|
|
console.error(err)
|
2023-05-22 18:11:31 -07:00
|
|
|
}
|
|
|
|
|
}
|