Hi!
I have an initial call to an API that gives me a list, that I then loop through and want to export the response from the 2nd call to the console. However, the console only seems to output the response of the initial call.
Help would be greatly appreciated.
Here is the Test Body
var isJson = false;
var TriggerEvent = ‘’;
var i;
var jsonData = ‘’;
try{
var dataResponse = JSON.parse(responseBody);
isJson = true;
}
catch(err)
{
console.log(‘responseBody is not JSON’);
}
if(isJson)
{
postman.setEnvironmentVariable(“arrayLength”, _.size(dataResponse.triggeringEvents) );
for (i = 0; i < environment.arrayLength; i++)
{
TriggerEvent = '';
postman.setEnvironmentVariable("TriggerEvent" , dataResponse.triggeringEvents[i]);
pm.sendRequest({
url: pm.environment.get("url") + '/api/v1/administrators/marketplaces/' + pm.environment.get("default_marketplace") + '/message_templates?triggeringEvent=' + pm.environment.get("TriggerEvent"),
method: 'GET',
header: 'X-Token:' + pm.environment.get("token"),
body: {
mode: 'json'
}
},
console.log(pm.response.json()) //This is giving the response from the the GET not the GET in the pm.sendRequest, how do you get that response outputted.
);
}
}