Zapier Javascript: 意外的令牌]

Zapier Javascript: Unexpected token ]

在 Zapier Zap 中,我从 Google 表格中提取数据并使用 JS 对其进行美化,以便稍后发送电子邮件。我遇到了以下消息的错误:

语法错误:意外的标记]

我在 zap 中的代码

const data = {
    "list_ids": [
    "a0b30126-69d6-4822-ac06-bf76c3ff4770"
    ],
    "contacts": [
    {
        "email": "email",
        "first_name": "name",
        "custom_fields": {
        "e5_T": "list",
        "e6_T": "y",
        "e7_T": "z"
    }
    ]
}

const res = await fetch('https://api.sendgrid.com/v3/marketing/contacts', {
    method: 'PUT',
    headers: {
        'Content-Type': 'application/json',
        'authorization': 'Bearer <<my api key>>'
    },
    body: JSON.stringify(data),
    })

.then(response => response.json())
.then(data => {
    console.log('Success:', data);
    })
.catch((error) => {
    console.error('Error:', error);
    });

return { res };

我使用了这个博客 https://joelaguero.com/how-to-add-a-sendgrid-contact-with-zapier-code-snippets/ 中的代码。作者说这对他有用。

这是因为你的 {} 多。 您可能忘记了在 custom_fieldscontacts.

中关闭 }