Files
AstralRinth/theseus_gui/src/helpers/fetch.js
Wyatt Verchere d968ad383c Discord and playtime (#462)
* initial

* Fixed java thing

* fixes

* internet check change

* some fix/test commit

* Fix render issues on windows

* bump version

---------

Co-authored-by: Jai A <jaiagr+gpg@pm.me>
Co-authored-by: Jai A <jai@modrinth.com>
2023-08-05 16:41:08 -07:00

19 lines
490 B
JavaScript

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)
}
}