2024-08-20 15:31:48 +00:00
|
|
|
export async function solarFetch(input: string, init?: RequestInit) {
|
2024-08-12 17:08:32 +00:00
|
|
|
const auth = useUserinfo()
|
|
|
|
const config = useRuntimeConfig()
|
|
|
|
|
2024-08-20 15:31:48 +00:00
|
|
|
if (!input.startsWith("http")) {
|
|
|
|
input = `${config.public.solarNetworkApi}${input}`
|
|
|
|
}
|
|
|
|
|
|
|
|
return await fetch(input, {
|
2024-08-12 17:08:32 +00:00
|
|
|
...init,
|
|
|
|
headers: {
|
|
|
|
...init?.headers,
|
2024-09-18 15:04:42 +00:00
|
|
|
Authorization: `Bearer ${await auth.getAtk()}`,
|
2024-08-12 17:08:32 +00:00
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|