In Requestly's API Client, how can I get the environment variables in a pre-request script?
I tried using rq.env.get("my_request_var")
but it throws error in console stating env is undefined
. I looked into the documentation but somehow not able to locate this piece. Even {{my_request_var}}
is not working.
The curly bracket notation works everywhere (headers, request body, query params and even the URL) except for scripts.
To get the value of the variable you need to use rq.environment
INSTEAD OF rq.env
so in your case rq.environment.get("my_request_var")
should work.
Here's the relevant part of the documentation for the same.