You've already forked AstralRinth
forked from didirus/AstralRinth
Migrate to Turborepo (#1251)
This commit is contained in:
18
apps/app/src/helpers/fetch.js
Normal file
18
apps/app/src/helpers/fetch.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ofetch } from 'ofetch'
|
||||
import { handleError } from '@/store/state.js'
|
||||
import { getVersion } from '@tauri-apps/api/app'
|
||||
|
||||
export const useFetch = async (url, item, isSilent) => {
|
||||
try {
|
||||
const version = await getVersion()
|
||||
|
||||
return await ofetch(url, {
|
||||
headers: { 'User-Agent': `modrinth/theseus/${version} (support@modrinth.com)` },
|
||||
})
|
||||
} catch (err) {
|
||||
if (!isSilent) {
|
||||
handleError({ message: `Error fetching ${item}` })
|
||||
}
|
||||
console.error(err)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user