Question 14
Consider a scenario involving localStorage, Promise chains, and Vue lifecycle hooks:
Scenario: A user authentication system where: On app initialization, the app checks localStorage for a stored user token• If a token exists, it validates the token asynchronously (via a Promise)• Based on validation, different UI components are rendered• The user navigates between different views• Code in mounted() hook:
Which of the following statements is/are CORRECT about this implementation?
If the page is refreshed while the Promise is pending, the token will be lost because localStorage is cleared on refresh
If token validation fails, the token is removed from storage, preventing automatic login on future page loads
The isAuthenticated flag might be false even though a storedToken exists, until the Promise validation completes
sessionStorage should be used instead of localStorage because user tokens should not persist across browser sessions
If the user navigates to a different route while validation is pending, the Promise will still complete and update the user data