Toolbox Server Script - getting nested API response bubble objects


so I am trying to sort an response of an products search API by a calculated value in a backend workflow with JavaScript via a Server Script from the Toolbox Plugin.
I managed to do this with one API, but struggling with another one where there is a nested array containing the necessary properties. This array always comes up empty or undefined in the server script. I could retrieve the values without problem on the client side. After hours of trying, I think this is either a limitation or a bug, but i might as well be doing it wrong :slightly_smiling_face:

So this is how the json looks:

      "brand": "Colgate",
      "display_name": "Cepillo dental Colgate blister 4 unidades",
      "price": 2.99,
      "promotions": [
          "description": "2ª ud al 50% dto. en selección colgate",
          "only_club_dia": true,
          "short_description": "SELECCIÓN COLGATE"
      "units_in_stock": 102

The array in question is the "promotions" array. Now in the client side script I am getting the contents of the description property of the only element in that array via this function:

//to get the promo description of an product
function getPromoDescription(item){
  var myPromotions = item.get('_api_c2_promotions')
  if (myPromotions == null) {
    return null;
  } else {
    var len = myPromotions.length();
    var myPromotionsList = myPromotions.get(0, len);

I followed the instructions from the toolbox help pages toolboxdocs server-script, which are great, but the results always come up undefined or with an empty array []

I currently think the problem is, that my "promotions" array is another Bubble API Response Data Type, which is not loaded before sending the Server Script to the AWS instance and therefore never populated.
This is what it looks like in the API connector as a nested list in my search element.

So yeah, any help or hints much appreciated. Even if its just a confirmation, that this is a limitation or a bug, so I can stop trying this and try a different approach.
Thanks :slight_smile:

@mishav maybe you can help me here.
Thank for all the great resources and for your plugin. I actually tried all your examples and hints in the docs and also this tip.
But my promotions property always comes back as a Bubble List with an empty array
E.g. when I try this:

var len = await properties.thinglist1.length();
var result = [];

for await (const item of properties.thinglist1) {
    result.push(await item.get("_api_c2_promotions"));

return JSON.stringify(result[0]);

        "_pointer": [],
        "_call_metadata": {

The object doesn’t have listProperties() nor lenght() and I cannot get the properties/values that should be inside the first (and only) element of that array.
Like I said, any hints much appreciated.