I’m using JavaScript to send data to the database and not using the default <form>
's submit.
let g_submitFormData = () =>
{
const request = new Request(
BASE_URL + "api/add",
{ headers: {'X-CSRFToken': csrftoken} }
);
return fetch(request, {
method: 'POST',
mode: 'same-origin',
body: JSON.stringify(Alpine.store('global_data'))
})
.then(response => response.json())
.then(response =>
{
data = response; console.log(data);
return data;
});
}
But now I am in a fix when I want to try sending in files as Input.
<input type="file" multiple x-model="$store.global_data.attachments" />