【问题标题】:Zapier Javascript: Unexpected token ]Zapier Javascript:意外的令牌]
【发布时间】:2021-01-09 12:33:25
【问题描述】:

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

SyntaxError: Unexpected token ]

我在 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_fields" 没有结束 }

标签: javascript sendgrid zapier


【解决方案1】:

这是因为您的{} 多。 您可能忘记在 custom_fieldscontacts 中关闭 }

【讨论】:

    猜你喜欢
    • 2014-11-29
    • 2015-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-23
    相关资源
    最近更新 更多