Laravel vue axios is action method and csrf needed for ajax forms ... | laravel vue axios csrf
IampostingaajaxfrominLaravelusingaxiosandvue,Ihavea@click="postData"buttonintheformthattogglesaaxiospostrequest:postData(){axios({method:post,url:appJS.base_url+/comment,responseType:json,data:comData}).then(function(response){})ButdoIstillneedtoaddtheaction,methodandcsrftomyform?
I am posting a ajax from in Laravel using axios and vue, I have a @click="postData" button in the form that toggles a axios post request:
postData() { axios({ method: post, url: appJS.base_url + /comment, responseType: json, data: comData }) .then(function(response) { })But do I still need to add the action, method and csrf to my form?
<form action="{{ url(/comment) }}" method="POST"> {{ csrf_field() }} </form>vs
<form></form>Everything works fine just using <form></form> but I wonder if there are any pros/cons?
I am making a ajax call in the background since I dont want the whole page to reload