[Vuejs]-Call post to vue with laravel error 419 csrf-token

2👍

It should be _token instead of csrf.

 data: {
            mensaje: '',
            pedidos: [],
             "_token": document.querySelector('meta[name="csrf-token"]').getAttribute('content'),
        },

Also instead of getting token from a query selector you can achive it like this too.

 data: {
     "_token":{{ csrf_token() }}
    },

1👍

If you use VueJS.
Route Laravel, you should put it in api.php instead of web.php

👤Beater

0👍

Finally, the problem comes by other part of code, so CSRF isn´t the problem.

👤Michu

Leave a comment