简体   繁体   中英

Retrieve user information with JWT Token, React Native and Redux

I am using React Native and Redux. When a user logs in, I send a request to my API and receive a JWT Token with the user object.

When I retrieve data, I am sending the token in my request, and it works very well.

However, on my Settings page, I want to show the user's email, name, and photo. Should I retrieve these every time the user wants to see the settings page or is this bad in terms of performance? I mean - there could be situations where the user's profile settings have changed, but it's very rarely, so it might be fine to just store their information separate from the token (or should I eventually decode the token)?

To me it seems more correct to always retrieve the most recent information from the server, so the app is always up-to-date, but I also fear that the app won't be scalable as more users sign up to the app, and retrieves their data both when signing in and when they look at their settings page.

I think,Once user logged into the app we will get the latest data stored in database in token, so we do not need to check again on setting screen. If user perform some modification then we are going to make a new request which will give us the latest updated data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM