I am trying to troubleshoot an environment variable problem. I am trying to see if postman can recognize the value, but when i refer to it after getting the results back, it keeps saying undefined in console.
Successful get request body:
{
“id”: 35438,
“user_id”: 35418,
“account_id”: 1,
“unique_id”: “d006”,
}
Testing to see if console sees the “user_id value” so I can store it in a variable later:
This displays the full response successfully:
var jsonData = pm.response.json();
console.log(jsonData);
console log:
(1) [{…}]
0: {…}
id: 35438
user_id: 35418
account_id: 1
unique_id: “d006”
However, if I do as below, it says “undefined”, instead of giving me “35418”
var jsonData = pm.response.json();
console.log(jsonData.user_id);
I tried to do
var jsonData = JSON.parse(responseBody);
console.log(jsonData.user_id);
I am getting the same result. What am I doing wrong?
Thanks.