2023-06-20 22:03:59 -04:00
|
|
|
import { getVersion } from '@tauri-apps/api/app'
|
2025-08-13 21:48:52 +01:00
|
|
|
import { fetch } from '@tauri-apps/plugin-http'
|
2023-05-22 18:11:31 -07:00
|
|
|
|
2023-08-05 16:41:08 -07:00
|
|
|
export const useFetch = async (url, item, isSilent) => {
|
2025-08-14 21:48:38 +01:00
|
|
|
try {
|
|
|
|
|
const version = await getVersion()
|
|
|
|
|
return await fetch(url, {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
headers: { 'User-Agent': `modrinth/theseus/${version} (support@modrinth.com)` },
|
|
|
|
|
})
|
|
|
|
|
} catch (err) {
|
|
|
|
|
if (!isSilent) {
|
2025-08-15 19:02:55 +01:00
|
|
|
throw err
|
|
|
|
|
} else {
|
|
|
|
|
console.error(err)
|
2025-08-14 21:48:38 +01:00
|
|
|
}
|
|
|
|
|
}
|
2023-05-22 18:11:31 -07:00
|
|
|
}
|