I'm trying to build an app based on a couple with Laravel and Vuejs.
I've implemented a method in Vue that sends POST login and gets an accessToken from back's Laravel. My next challenge is to get an authorized user's data to show in NavBar and so on. What is the right way to do it?
Way 1: The login method on the app's back returns not only the accessToken. He also puts a user's data into the response. So, after the login request, Vue gets the accessToken and user's data that I put into localStorage inside of Vuex.
Way 2: The login method returns only the accessToken. After getting accessToken, Vue makes one more request to get a profile of the authorized user by the accessToken.
What's the correct way to get an authorized user's profile?
Both approaches are correct, but I think there is no need to get the profile with the login response .
I will only return the accessToken and store it somewhere safe, and when you need the user profile you make another request.
and for showing different types of NavBars,you can use an event emitter to trigger different actions (login, logout)