Hiya.
I need help with something that must be a super basic JavaScript syntax question. Sadly it’s not basic enough for me to solve after spending a few hours on this (clearly my JavaScript skills are super poor). If someone can help, I’d be hugely grateful.
In short - I successfully implemented SendGrid v2 Web API with Wix using this article
Velo Tutorial: Sending an Email on Form Submission | Help Center | Wix.com.
To use templates with parameters in SendGrid, I need to send an addditional smtpapi parameter, but for the life of me I can’t figure out how to create the JSON object (or string) to do so. The best I was able to do is create a hard-coded function, which means I can’t do something basic like passing parameters.
Look at the constant below - basically I need to be able to create this JSON object with a variable parameter for fullname and for address. How do I do that?
I’ll spare you the list of various methods I tried- whatever I did, it didn’t work with SendGrid and returned an error, probably because I’m not formatting the object or string correctly.
Any help would be hugely appreciated.
const smptapi = `
{
"sub":
{
":fullname": ["I want this to a be parameter! not hard-coded!"],
":address": ["I want this to a be parameter! not hard-coded!"]
},
"filters": {
"templates": {
"settings": {
"enable": 1,
"template_id": "123c61fc-bb06-4fa9-9ba5-1234eea6bb"
}
}
}
}`;