I followed the flow for declaring variable token with initial value null and then using the setToken function to reassign the value outside of the module when user logs in.
This flow breaks for me when I refresh the page. After refreshing the page my http server requests return 401 Unauthorized with 'invalid token'. It seems that refreshing page reloads the module and variable token is null again. Dev tools show Authorization header being set with value null.
Anybody else had the same problem? Is it my code or is the flow in the example broken?