如何使用Vuejs和Laravel获取当前经过身份验证的用户ID? [英] How to get current authenticated user id using Vuejs and Laravel?
本文介绍了如何使用Vuejs和Laravel获取当前经过身份验证的用户ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用Vuejs作为前端,我只想从Laravel获取当前登录的用户ID并显示它.我该怎么办?
I am using Vuejs as my frontend and I would simply like to get the current logged in user's id from Laravel and display it. How would I do this?
推荐答案
通过多种方式获取身份验证用户ID 了解更多
by many way to get auth user id read more
Auth::user()->id;
Auth::id();
通过vue js
$http.get('api/user').then(response => {
console.log(response.body);
})
这篇关于如何使用Vuejs和Laravel获取当前经过身份验证的用户ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文