samedi 5 décembre 2015

TokenMismatchException using Laravel 5.1 and VueJS

I am trying to use VueJS to make a POST request. But, I cannot get past a TokenMismatchException. I have this meta tag in the main Blade template:

<meta name="token" id="token" content="{!! csrf_token() !!}">

And this at the top of my VueJS file:

Vue.http.headers.common['X-CSRF-TOKEN'] = document.querySelector('#token').getAttribute('value');

Here is the line in my VueJS method that invokes the POST:

this.$http.post('ads/create/store', this.content);

I have tried for way too long to get the token accepted. Can anyone out there help?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire