Using user input to further filter api

I have an api response:

{
  "statusCode": 200,
  "body": [
    {
      "address": "WARSZAWA, STREET A",
      "floors": [
        {{
          "imgPl": "/rrdb.nsf/0/136074D3E0AAAA9EC12584FE00350D41/$File/p0+icons.png",
          "imgEn": "/rrdb.nsf/0/136074D3E0AAAA9EC12584FE00350D41/$File/p0+icons.png",
          "id": "0"
        },
        {
          "imgPl": "/rrdb.nsf/0/75345AE6FEC20331C1258504002ED968/$File/p1+icons.png",
          "imgEn": "/rrdb.nsf/0/75345AE6FEC20331C1258504002ED968/$File/p1+icons.png",
          "id": "1"
        },
        {
          "imgPl": "/rrdb.nsf/0/B347F846672BAEB7C12584FE0035700C/$File/p2+iconsEN.png",
          "imgEn": "/rrdb.nsf/0/B347F846672BAEB7C12584FE0035700C/$File/p2+iconsEN.png",
          "id": "2"
        },
        {
          "imgPl": "/rrdb.nsf/0/C08E6F75A82380BFC12584FE003580B4/$File/p3+icons.png",
          "imgEn": "/rrdb.nsf/0/C08E6F75A82380BFC12584FE003580B4/$File/p3+icons.png",
          "id": "3"
        },
        {
          "imgPl": "/rrdb.nsf/0/1D3E943B8EC6D474C12584FE00358391/$File/p4+icons.png",
          "imgEn": "/rrdb.nsf/0/1D3E943B8EC6D474C12584FE00358391/$File/p4+icons.png",
          "id": "4"
        }
      ],
      "name": "STREET A",
      "lastModification": "2021-12-13 10:09",
      "floorsCount": "4",
      "id": "WAW_STA",
      "type": "",
      "photos": [
        {
          "nazwa": "streeta.jpg",
          "url": "/rrdb.nsf/0/4951FA4EFC2EF47CC125856600335557/$File/Goleszowska+%C5%82%C4%85%C4%87%C5%BA%C4%98%E2%80%94+kopia.jpg"
        }
      ]
    },
    {
      "address": "WARSZAWA, STREET B",
      "floors": [
        {
          "imgPl": "/rrdb.nsf/0/58BF371C83A68088C12584FE003165F8/$File/p0-pl.png",
          "imgEn": "/rrdb.nsf/0/58BF371C83A68088C12584FE003165F8/$File/p0-en.png",
          "id": "0"
        },
        {
          "imgPl": "/rrdb.nsf/0/64D881792F5FB04EC125834B00489629/$File/p1-pl.png",
          "imgEn": "/rrdb.nsf/0/64D881792F5FB04EC125834B00489629/$File/p1-en.png",
          "id": "1"
        },
        {
          "imgPl": "/rrdb.nsf/0/85ECB3D6F295D15BC125834B0048912A/$File/p2-pl.png",
          "imgEn": "/rrdb.nsf/0/85ECB3D6F295D15BC125834B0048912A/$File/p2-en.png",
          "id": "2"
(...)

in first entity I list avaiable locations to the user:

  • street A
  • street B
  • street C

but in another entity, I would like to list a floor numbers (“id”,number depends on location) on the base of the location that user choose from the list.

"Please select a floor of Street A building:

  • 0
  • 1
  • 2
    (…)"

How can I call the exact, choosen by the user address [eg. Street A] to list the id’s?

Hello @michal.krauzowicz :smiley:,

Welcome to Kore Community :clap:

To access street names you will have to use - response.body[i].name;
For Floor list - response.body[i].floor[j].id;

We have the following example with the data given:

We set the following code as a context variable(context.newInfo) in script node.

“statusCode”: 200,
“body”: [
{
“address”: “WARSZAWA, STREET A”,
“floors”: [
{
“imgPl”: “/rrdb.nsf/0/136074D3E0AAAA9EC12584FE00350D41/$File/p0+icons.png”,
“imgEn”: “/rrdb.nsf/0/136074D3E0AAAA9EC12584FE00350D41/$File/p0+icons.png”,
“id”: “0”
},
{
“imgPl”: “/rrdb.nsf/0/75345AE6FEC20331C1258504002ED968/$File/p1+icons.png”,
“imgEn”: “/rrdb.nsf/0/75345AE6FEC20331C1258504002ED968/$File/p1+icons.png”,
“id”: “1”
},
{
“imgPl”: “/rrdb.nsf/0/B347F846672BAEB7C12584FE0035700C/$File/p2+iconsEN.png”,
“imgEn”: “/rrdb.nsf/0/B347F846672BAEB7C12584FE0035700C/$File/p2+iconsEN.png”,
“id”: “2”
},
{
“imgPl”: “/rrdb.nsf/0/C08E6F75A82380BFC12584FE003580B4/$File/p3+icons.png”,
“imgEn”: “/rrdb.nsf/0/C08E6F75A82380BFC12584FE003580B4/$File/p3+icons.png”,
“id”: “3”
},
{
“imgPl”: “/rrdb.nsf/0/1D3E943B8EC6D474C12584FE00358391/$File/p4+icons.png”,
“imgEn”: “/rrdb.nsf/0/1D3E943B8EC6D474C12584FE00358391/$File/p4+icons.png”,
“id”: “4”
}
],
“name”: “STREET A”,
“lastModification”: “2021-12-13 10:09”,
“floorsCount”: “4”,
“id”: “WAW_STA”,
“type”: “”,
“photos”: [
{
“nazwa”: “streeta.jpg”,
“url”: “/rrdb.nsf/0/4951FA4EFC2EF47CC125856600335557/$File/Goleszowska+%C5%82%C4%85%C4%87%C5%BA%C4%98%E2%80%94+kopia.jpg”
}
]
}
]
}

And used the following code to print the info:

var compInfo= context.newInfo.body;

for(var i=0; i<compInfo.length; i++)
{
 print ("Street Name:  " + compInfo[i].name +"\n");
var floorList = context.newInfo.body[i].floors;
for(var i=0; i<floorList.length; i++)
    {
        print("Floor Id:  " + floorList[i].id +"\n")
    }
}

The response is show as below:
image

Feel free to modify the logic for our usecase. Hope this helps!

Thank you for stopping by!!