Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

158
Visualizações
How to load authorized user's data in vuejs in the right way

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?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

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)

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda