Need help with JavaScript in code block

Hey everyone! I’m trying to replicate this pretty simple automation from make.


It is aimed to extract product data in airtable, create a JSON for EACH product

to then pass to HTTP module to upload each product to VoiceFlow chatbot’s knowledge base in table format.

The main problem I’m facing is writing a proper JS code for the flow to work. I’m not really a coder so I find it very difficult. I did my best trying to create and adapt the code using GPT but it still runs with errors.
I had no problem making it work with ‘run once for all items’ mode, but what I need is ’ run once for each item’ to replicate make’s JSON module.

I’d be very grateful if someone can help me out or point in the right direction.

Hi @Matvey_Zhukov,

To keep things simple, why not just use a Set node instead of Code?

I’ve created one for you, feel free to edit it according to your needs:

This is a manual mapping. If you need the corresponding JSON, it would look like this:

{
  "body": {{ JSON.stringify($json.body) }},
  "price": {{ $json.price }},
  "title": {{ JSON.stringify($json.title) }},
  "mainImage": {{ JSON.stringify($json.mainImage) }},
  "productUrl": {{ JSON.stringify($json.productUrl) }},
  "productCategory": {{ JSON.stringify($json.productCategory) }},
  "inventoryQuantity": {{ $json.inventoryQuantity }}
}

Let me know if you need help adjusting it further…

Thank you very much man

1 Like