我有一个看起来像这样的组件:
<subscription :subscriptions="{{json_encode($subscriptions)}}"></subscription>
现在我想在该组件中发布帖子请求。我是这样做的:
methods: {
unSubscribe(subscription) {
MessageService.unSubscribe(subscription)
.then(() => {
this.subscriptions = this.subscriptions.filter((item) => subscription.id != item.id );
});
}
}
unSubscribe (message) {
return axios.post('/api/message/' + message.slug + '/unsubscribe');
},
但是当我dd()api.php中经过身份验证的用户时:
Route::group(['middleware' => ['auth:api']], function () {
Route::post('/message/{message}/unsubscribe', function() {
dd(Auth::user());
});
});
我收到空?
我认为Laravel可以让用户通过CSRF
令牌?
在bootstrap.js
我得到了:
window.axios.defaults.headers.common = {
'X-Requested-With': 'XMLHttpRequest'
};
我该如何处理?