I have a vue component that contains a form with inputs - i'm using the component to submit data to laravel endpoint.
So the form is simply set up like this in a component called Sale.vue
<template name="sale">
<form class="form-horizontal" role="form" action="/sales/save" method="POST">
I already have csrftoken set up in the head tag of the containing blade file - index.blade.php
<script>
window.Laravel = {!! json_encode([
'csrfToken' => csrf_token(),
]) !!};
</script>
The index.blade yields sales page, which in turn simply contains the custom component
I would have thought since the main page has the csrftoken already, it should work. However upon submitting the form i'm getting the tokenMismatchException error.
I'm using laravel 5.4 out of box setup for vue, so it contains the bootstrap.js which has the line
window.axios.defaults.headers.common['X-CSRF-TOKEN'] = window.Laravel.csrfToken;
Not sure how that impacts as i'm not yet using ajax for the submit.
How can i get the vue component to work with the token ? Naturally, i cannot do another {{csrf_field()}} inside the component form and {!! csrf_field() !!} just prints the literal on the page?