// Save the login response to a variable
var tokenStr = pm.response.json().data.login;
//parse out the Key 'token' and get its value
const key = Object.keys(tokenStr)[0];
passportToken = Object.key(tokenStr[0])
//set key value to passportToken variable
I’m getting a TypeError Object.key is not a function and need help to parse out the value for the key ‘token’
Updated the script by setting the variable as below:
// Save the login response to a variable
var passportToken = pm.response.json().data.login.token;
// Set the login response to passportToken Collection variable
pm.collectionVariables.set("passportToken", passportToken);
//print console token value
console.log(pm.response.json().data.login.token);
Console log shows the Variable is assigned to just the token value
that is used in the subsequent request, working as expected