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

282
Views
Axios POST Error: Request failed with status code 419

I am trying to make a post request with Axios + Laravel 7. And I got this error message:

Error: Request failed with status code 419

My Javascrip code:

axios.defaults.headers.common = {
    'X-Requested-With': 'XMLHttpRequest',
    'X-CSRF-TOKEN': window.csrf_token
};
axios.defaults.withCredentials = true;

var formEditEmpresa = document.getElementById("formeditEmpresa");

function validareditEmpresa() {

    var formData = new FormData(formEditEmpresa);

    axios({
        method: 'post',
        url: "editarLoja",
        headers: { "Content-Type": "multipart/form-data" },
        data: formData,
    })
        .then(res => {
            // listarChamados.innerHTML = res.data;
            console.log(res);
        })
        .catch(err => {
            console.error(err);
        })
    return false;
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try changing the headers to this syntax:

  headers: {
    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  }

As show in Laravel docs.

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!