how to display uesrname after the user logged in without filling the user details on login

60 Views Asked by At

I would like to display my user fullname on profile page. I know I need to set the user somehow, but I do not know how. I do not have the user fullname from login input, I got it in the server. I do not want to use an HTTP GET request for that.

I saw some similar questions, but I could not figure it out on my code.

So, how can I get the user fullname from the server? What do I need to do on service? How can I use the data in the profile component, and how I display the user fullname.

2

There are 2 best solutions below

0
Vaibhav Mahajan On BEST ANSWER

You can add users' full name in the login success response of the server and store it in local storage, so can get the user's full name on any component. Using this you save the additional API call for the full name.

0
Md Rehan On

At the time of login save userid in cookies or any storage after login use that userid to fetch user details from API now fetch and display user full name.