Files
Modrinth-plus/theseus_gui/src/helpers/fetch.js

14 lines
351 B
JavaScript
Raw Normal View History

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, {
headers: { 'User-Agent': 'modrinth/theseus (support@modrinth.com)' },
})
2023-05-22 18:11:31 -07:00
} catch (err) {
handleError({ message: `Error fetching ${item}` })
console.error(err)
2023-05-22 18:11:31 -07:00
}
}