I got a response from a get request as an object and added it to an environment variable. now I want to use it in another request params but I don't know how to do it.
I got a response from a get request as an object and added it to an environment variable. now I want to use it in another request params but I don't know how to do it.
environment variables are just text, so you might need to strigify the json response object and parse it before executing the next request.
There are pre-requests tests that you could use to read and parse the environment variable.
https://learning.postman.com/docs/writing-scripts/pre-request-scripts/#pre-request-scripting-example
You should use JSON stringfy in order to save in the environment. after that use the Pre-request Script in order to add query params and JSON parse to get data from the environment. follow these steps as a sample code.
1- pm.environment.set("key", JSON.stringfy(object))
2- go to Pre-request Script
3- var data = JSON.parse(pm.environment.get("key"))
4- pm.request.url.addQueryParams([`param=${data.child}`])