Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

67
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda