Files
Modrinth-plus/apps/app-frontend/src/helpers/fetch.js

19 lines
425 B
JavaScript
Raw Normal View History

import { getVersion } from '@tauri-apps/api/app'
import { fetch } from '@tauri-apps/plugin-http'
2023-05-22 18:11:31 -07:00
export const useFetch = async (url, item, isSilent) => {
try {
const version = await getVersion()
return await fetch(url, {
method: 'GET',
headers: { 'User-Agent': `modrinth/theseus/${version} (support@modrinth.com)` },
})
} catch (err) {
if (!isSilent) {
throw err
} else {
console.error(err)
}
}
2023-05-22 18:11:31 -07:00
}