[n00b question] How to transform response data

Hello,

Is there a way to map a GraphQL response into a table without using the Functions?

It looks something like this and comes out as a json but not table:

{
   "orders":{
      "parameter":{
         "parameter2":[
            {
               "theActualOrder":{
                  "id":"string",
                  "products":[
                     {
                        "name":"Name of the product",
                        "sku":"SKU123",
                        "quantity":1,
                        "price":{
                           "net":23,
                           "gross":23
                        }
                     }
                  ],
                  "customer":{
                     "lastName":"Lastname",
                     "firstName":"Firstname",
                     "addresses":[
                        {
                           "type":"billing",
                           "firstName":null,
                           "lastName":null,
                           "city":"City",
                           "state":null,
                           "country":"Country",
                           "postalCode":"1234",
                           "street":"Street",
                           "street2":null,
                           "streetNumber":"1",
                           "phone":null,
                           "email":null
                        },
                        {
                           "type":"delivery",
                           "firstName":null,
                           "lastName":null,
                           "city":"City",
                           "state":null,
                           "country":"Country",
                           "postalCode":"1234",
                           "street":"Street",
                           "street2":null,
                           "streetNumber":"1",
                           "phone":null,
                           "email":null
                        }
                     ]
                  }
               }
            }
         ]
      }
   }
}

Ideally I would want it something like:

{ "data": [ { "id":"String", "products": [ { ... } ] } ] }

Thanks in advance

Hi @ericsonmartin

Welcome to the community.
Not exactly sure that this would be what you are looking for, but it should send you in the right direction. If you have any further questions please feel free to ask.
Also the Courses that are available for n8n might help you some more aswell.

Function node below is just to put in your sample data. Set node is the node you are looking for I think.

1 Like

Many thanks for the swift response.

I tried the code and only get =[not found]

Does n8n offer paid support? I can’t share all details of the API here.

Hi @ericsonmartin

Thats probably because the wrong fields reference is set. Should be an easy fix.

N8n has partners that offer paid support.
I am one of those partners. I will sent you my contact info in a direct message.

1 Like