Invoices can be uploaded
This commit is contained in:
@@ -8,6 +8,8 @@ export function useAjax() {
|
||||
|
||||
async function request(url, options = {}) {
|
||||
loading.value = true
|
||||
const isFormData = options.body instanceof FormData
|
||||
|
||||
error.value = null
|
||||
data.value = null
|
||||
|
||||
@@ -15,14 +17,19 @@ export function useAjax() {
|
||||
const response = await fetch(url, {
|
||||
method: options.method || "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
'X-CSRF-TOKEN': csrfToken,
|
||||
...(isFormData ? {} : { 'Content-Type': 'application/json' }),
|
||||
...(options.headers || {}),
|
||||
},
|
||||
body: options.body ? JSON.stringify(options.body) : null,
|
||||
body: isFormData
|
||||
? options.body // ✅ FormData direkt
|
||||
: options.body
|
||||
? JSON.stringify(options.body)
|
||||
: null,
|
||||
})
|
||||
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`)
|
||||
|
||||
const result = await response.json()
|
||||
data.value = result
|
||||
return result
|
||||
@@ -35,6 +42,7 @@ export function useAjax() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function download(url, options = {}) {
|
||||
loading.value = true
|
||||
error.value = null
|
||||
|
||||
Reference in New Issue
Block a user