How to read an environment variable


Hi Gang,

I am building an app on which I ask an API for a authentication token. The token is stored using Storage.

The problem is that I ask the token on the authentication page (the home page), and when I need to build any other feature, I have to navigate from the beginning of the app (login page) until the level where I am implementing the new feature. In order to save time on the implementation of the new feature, I’d like to mock the authentication token by starting the ionic server and defining an environment variable, so that in my source code, I can check if the environment variable is set, if it is set, I’ll take it’s value as the authentication token and I’ll override the whole session logic.

I’ve seen the documentation, I know that maybe I can add a key-value pair inside this file: ionic.config.json but I don’t know how to access it’s content through my source code on the application.