I'm trying to pass to my php server a request with some values, using axios. values contain a string variable and an array.
The console log before axios contain correctly all the data, but when I recive everything in php, I lose the array data, that become empty, and I have just the string.
var params = {
request: "INSERIMENTO_GARA"
}
params.valori = Object.assign([],this.myRace),
console.log(params);
axios.post('../server/post.php',params, {
headers: {
Accept: "application/json",
"Content-Type": "application/json;charset=UTF-8",
},
})
.then((response) => {
console.log(response.data);
})
.catch((error) =>{
console.log(error)
})
On server side I simply:
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: *");
header("Content-Type: application/json");
$body = file_get_contents('php://input');
echo $body;
die();
These are the console log before the axios request and of the response:
{request: 'INSERIMENTO_GARA', valori: Array(0)} request: "INSERIMENTO_GARA" valori: [id: 0, nome: 'ciao', data: '2022-01-01', dist: '10', org: '11', …] [[Prototype]]: Object
{request: 'INSERIMENTO_GARA', valori: Array(0)} request: "INSERIMENTO_GARA" valori: [] [[Prototype]]: Object
Really don't understand the issue.