Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

65
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!