Environment Variables
Last updated
Last updated
Environment variables allow developers to switch between DEV and PROD for example
It allows for definition of different variables based on needs
Allows to define variables dynamically
After this has been defined, you can call it in the operation path:
So to save some time, we can automate the definition of the JWT as an environment variable through code
This should be done under the login
path operation as to define it directly as you log in
Navigate to the Tests
tab and select Set an environment variable
Use the following code to set it dynamically
The above code sets the environment variable as JWT
with the value fetching first the response, then transforming it into a JSON output from which the variable named in the return output is called
In our case access_token
but can be anything as it's app defined under the route return
After this is defined, we can call it under the authorization tab as {{JWT}}
to always have it update on login