0๐
<html>
<head>
<script>
// rename myToken as you like
window.myToken = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>
</script>
</head>
add common header :
<script>
window.axios.defaults.headers.common = {
'X-Requested-With': 'XMLHttpRequest',
'X-CSRF-TOKEN' : window.myToken
};
</script>
in your methods
methods: {
deletePet(id){
var petid = id;
window.axios.delete('/client/pet/', {params:{'id': petid})
.then(response => this.onSubmitSuccess(response))
.catch(error => this.onSubmitError(error));;
console.log('Pet Id' + petid);
}
},
laravel route :
Route::delete('client/pet/{id}', 'ClientController@deletePet')->name('client.pet.delete');
Source:stackexchange.com