Fetching JWT token each refresh

Viewed 25

What my code is doing currently is calling a function that calls an api that gives a new access token every time the page gets refreshed, or to be more specific i have a pinia store that has a function that adds the data to the store when called and this function is being called when the page refreshes.

I am doing this because I have a thing that says "logged in as x" on the navbar and to get that info I go check if the refresh token is valid and fetch the username at the same time.

I'm wondering if this is a bad idea and if I should do it some other way, like storing the username in localstorage/cache/cookies

(sorry for bad phrasing)

0 Answers
Related