If the API response is an array then you will have to use proper formatting to print the objects of the array.
For example:
If context.<servicenode>.response.body.queryResult – with queryResult being part of the response body has the relevant data which is an array then you may use script as below:
var data= context.<servicenode>.response.body.queryResult;
if (data.length>1)
{
var data= context.<servicenode>.response.body.queryResult;
for(var i=0;i<data.length;i++){
var currentItem = {};
CurrentItem = {
Name: data[i].PersonName ,
SSN: data[i].SSN ,
Phone: data[i].Phone,
Email: data[i].Email
}
context.session.BotUserSession.queryResult.push(CurrentItem)
}
}
And when printing the data, use for loop to print data from context.session.BotUserSession.queryResult[i]
This is simply one of the ways to handle the response. You may use other scripting logics per your choice. Hope this helps
What is api result is in this format
“statusCode”: 200,
“body”: {
“parsedTime”: [
{
“body”: “now”,
“start”: 0,
“value”: “2024-10-11T19:14:55.595+05:30”,
“end”: 3,
“dim”: “time”,
“latent”: false,
“grain”: “second”,
“formatted”: “11/10/2024”,
and I want to use “formatted” value to show in next message node…
context..response.body. have tried this, not working