Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

68
Vistas
Problem sending Vuejs Array with Axios Post

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.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda