Capital/utils/request.ts

13 lines
352 B
TypeScript
Raw Normal View History

2024-08-12 17:08:32 +00:00
export async function solarFetch(input: string | URL | globalThis.Request, init?: RequestInit) {
const auth = useUserinfo()
const config = useRuntimeConfig()
return await fetch(`${config.public.solarNetworkApi}${input}`, {
...init,
headers: {
...init?.headers,
"Authorization": `Bearer ${await auth.getAtk()}`,
},
})
}