Capital/utils/request.ts

17 lines
381 B
TypeScript
Raw Normal View History

export async function solarFetch(input: string, init?: RequestInit) {
2024-08-12 17:08:32 +00:00
const auth = useUserinfo()
const config = useRuntimeConfig()
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
},
})
}