I found the answer myself:
If you're gonna work with a vue-component, you should just add the token to that component instead. Otherwise it won't go with your ajax request. So put this part underneath the template in the component:
http: {
root: '/root',
headers: {
'X-CSRF-Token': $('meta[name=_token]').attr('content')
}
},
Do this to check if your token was properly sent inside the headers:
- Go to google chrome, open dev-tools, go to the network tab and Reload.
- Make the ajax call and look at the file added in the network tab, open it and go to the 'Headers' tab.
- Look at the bottom where it says: 'Request Headers' and check if the token was properly added in the request.