Capital/utils/request.ts
2024-09-18 23:04:42 +08:00

17 lines
381 B
TypeScript

export async function solarFetch(input: string, init?: RequestInit) {
const auth = useUserinfo()
const config = useRuntimeConfig()
if (!input.startsWith("http")) {
input = `${config.public.solarNetworkApi}${input}`
}
return await fetch(input, {
...init,
headers: {
...init?.headers,
Authorization: `Bearer ${await auth.getAtk()}`,
},
})
}