Describe the problem/error/question
I’m not fluent with js, come mostly from the PHP/bash world.
I have the data below, and I need to create invoice line items for each billing object below - however the API (CreateInvoice - WHMCS Developer Documentation) takes query params in the url encoded array format: lineitemX where X is the array index.
How do I transform the data? I tried using the code node and use forEach on the billing object:
const itemlines = {};
$input.item.json.billing.forEach(function (value, i) {
itemlines[i] = "value";
});
but that gives me syntax errors.
What is the error message (if any)?
Please share your workflow
[
{
"client_id":
100,
"billing":
[
{
"domain":
"testdomain123.com",
"active_email_accounts":
44
},
{
"domain":
"testdomain456.com",
"active_email_accounts":
1
}
],
"sum":
45
}
]
Information on your n8n setup
- n8n version: 1.39.1
- Database (default: SQLite): sqlite
- n8n EXECUTIONS_PROCESS setting (default: own, main): own
- Running n8n via (Docker, npm, n8n cloud, desktop app): docker
- Operating system: debian11