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

257
Views
Empty array on $_POST when I send data with fetch

I am trying to send data from JavaScript with fetch to PHP but in PHP I get empty array when I do $_POST.

async function updatesProf(data) {

    const dataUpdate = {
        method:"POST",
        headers: {
            'Accept':'application/json',
            'Content-Type':'application/json',
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        },
        body: JSON.stringify({ data: data })
    };

    await fetch('synthese', dataUpdate)
    .then(response => response.json()).then(res => data )
    .catch(error => console.log("Error: "+error));

}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Classic Problem, if you send your $_Post with Javascript.

Try with:

$_POST = json_decode(file_get_contents('php://input'), true);
if(isset($_POST)){
    var_dump($_POST); 
}
about 4 years ago · Juan Pablo Isaza Report
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!