Make routing decision based on data of Vue instance



In a beforeEach navigation guard, I want to make a decision based on whether someone is currently logged in.

This works when the application is already loaded, but not for the first page load, because is not initialized yet.


Browser shows “Hello”
Console output: “Joe”

Browser shows “Please log in”
Console output: undefined

In the repro example I hardcoded the user name, but normally I would populate the root instance’s data from a window variable.

This doesn’t seem to work anymore.