How to set a value from a row of response to environment variable?

How to set a value from a row of response to environment variable?

The response:

"Status": 0,
 "Code": 0,

“Message”: “Found total of 345 items”,
“Data” : …

In this case I need to set the environment variable: env_num_of_items= 345
Thanks!

You can use below sample to achive this. There are many other ways to exact them.

let jsonResponse=pm.response.json();
let message=jsonResponse.Message;

let totalItems=message.replace(/\D/g,'');
console.log(totalItems);

pm.environment.set("env_num_of_items", "totalItems");

1 Like