Files
Supervisor/composables/useApiAuth.ts
2026-03-19 10:24:41 +01:00

21 lines
517 B
TypeScript

export const apiFetch = $fetch.create({})
export function apiRequest(input: RequestInfo | URL, init: RequestInit = {}) {
return fetch(input, withApiAuth(init))
}
export async function downloadApiFile(url: string, fileNameFallback: string) {
const link = document.createElement("a")
link.href = url
link.download = fileNameFallback
link.style.display = "none"
document.body.appendChild(link)
link.click()
link.remove()
}
export function withApiAuth(init: RequestInit = {}) {
return { ...init }
}