Laravel通过vue获得用户

时间:2017-01-30 13:08:34

标签: javascript laravel vue.js

我有一个看起来像这样的组件:

<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'
};

我该如何处理?

0 个答案:

没有答案