I’m working on a Zapier automation that pulls information from a spreadsheet and processes it with JavaScript before sending it via email. However, I keep getting this error message:
SyntaxError: Unexpected token ]
Here’s my current code:
const payload = {
"subscriber_lists": [
"b1c40237-78e7-4933-bd17-cf87d4ff5881"
],
"users": [
{
"email_address": "[email protected]",
"given_name": "John",
"properties": {
"field_1": "value1",
"field_2": "value2",
"field_3": "value3"
}
}
]
}
const response = await fetch('https://api.sendgrid.com/v3/marketing/contacts', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'authorization': 'Bearer <<token>>'
},
body: JSON.stringify(payload)
})
.then(res => res.json())
.then(result => {
console.log('Request successful:', result);
})
.catch((err) => {
console.error('Request failed:', err);
});
return { response };
I found this code in a tutorial and the author mentioned it worked fine for them. Can anyone help me figure out what’s causing this bracket error?