mercredi 24 janvier 2018

419 (Unknown Status) Error for POST request using AXIOS and Laravel

Sorry to bother all of u. Have searched lots of time.tried the probable solution too. I have set the csrf_token using meta tag

  <meta name="csrf-token" content="">

My post request is like the below

tryAuth () {

  if (this.$refs.form.validate()) {

    let _this = this

    axios.post('/trylogin',_this.loginInfo, {
      headers: {
        //'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
      },
      //withCredentials: true
    }).then(function(response){

      console.log(response.data)

    })
    .catch(function(error){

    })

  }

I have tried both using with the headers and without the headers. Sometimes the response is ok but sometimes it shows 419 error response.

I am using Laravel 5.5 and AXIOS latest version. Any help would be appreciated. I have found some solution and tried but didn't work for me.

Thanks :)



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire