I am trying to set an environment variable by capturing a node from the Response Body of an api, where the node contains two hyphenated words.
My script is - postman.setEnvironmentVariable("Token", jsonData.access-token);
- This keeps returning ReferenceError: token is not defined
The node in the Response Body is - {"access-token": "<token>"}
I have tried using this script - postman.setEnvironmentVariable("Token", jsonData.access/-/token/);
- This script sets the keyword "Token" as an environment key but does not capture the value of the actual token from the Response Body.
Does anyone know the solution to this problem?