I am trying to send data from JavaScript with fetch
to PHP but in PHP I get empty array when I do $_POST
.
async function updatesProf(data) {
const dataUpdate = {
method:"POST",
headers: {
'Accept':'application/json',
'Content-Type':'application/json',
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
body: JSON.stringify({ data: data })
};
await fetch('synthese', dataUpdate)
.then(response => response.json()).then(res => data )
.catch(error => console.log("Error: "+error));
}