fix of the json upload format
This commit is contained in:
@@ -165,12 +165,22 @@
|
|||||||
|
|
||||||
const formData = new FormData(form);
|
const formData = new FormData(form);
|
||||||
|
|
||||||
|
const csrfToken = document.querySelector('meta[name="csrf-token"]')?.getAttribute('content');
|
||||||
|
|
||||||
|
const fetchOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData,
|
||||||
|
credentials: 'include'
|
||||||
|
};
|
||||||
|
|
||||||
|
if (csrfToken) {
|
||||||
|
fetchOptions.headers = {
|
||||||
|
'X-CSRFToken': csrfToken
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/upload_csv_batch', {
|
const response = await fetch('/upload_csv_batch', fetchOptions);
|
||||||
method: 'POST',
|
|
||||||
body: formData,
|
|
||||||
credentials: 'include'
|
|
||||||
});
|
|
||||||
|
|
||||||
// Antwort einmalig als Text auslesen, um sowohl JSON als auch HTML-Fehler abzufangen
|
// Antwort einmalig als Text auslesen, um sowohl JSON als auch HTML-Fehler abzufangen
|
||||||
const responseText = await response.text();
|
const responseText = await response.text();
|
||||||
|
|||||||
Reference in New Issue
Block a user