I want to POST an array with axios
, however it is not working.
The array to POST:
[
{
"Nombre": "Remera",
"Precio": "1599",
"Photo": null,
"Stock": [
{
"id": 0,
"talle": "M",
"cantidad": "12"
},
{
"id": 1,
"talle": "S",
"cantidad": "14"
},
{
"id": 2,
"talle": "XS",
"cantidad": "6"
}
]
}
]
The data posted:
{
"Nombre": "Remera",
"Precio": "1599",
"Photo": null,
"Stock": [
{
"id": 0,
"talle": "M",
"cantidad": "12"
},
{
"id": 1,
"talle": "S",
"cantidad": "14"
},
{
"id": 2,
"talle": "XS",
"cantidad": "6"
}
]
}
Can someone help me on this one? Thanks!
You can not send the pure array.
You have to send the JSON as object and add the identifier to your array as below:
{
"data": [
{
"Nombre": "Remera",
"Precio": "1599",
"Photo": null,
"Stock": [
{
"id": 0,
"talle": "M",
"cantidad": "12"
},
{
"id": 1,
"talle": "S",
"cantidad": "14"
},
{
"id": 2,
"talle": "XS",
"cantidad": "6"
}
]
},
{...nextObject},
{...nextObject}
]
}