Help needed with 'wix-fetch' to send email using SendGrid

Hello Everybody,

I would like wix-fetch to send email from wix code via a third party API provided by SendGrid.

My codes are as follows:

fetch(“https://api.sendgrid.com/v3/mail/send”,
{method: ‘POST’,
headers: {‘Authorization’: ‘Bearer SG.rZ96miEdQXKohaalqOS65g.BQ_TaC83Fs1TnqFTvFDmiPmaBq9mPJRAPUBvir_Xg’, ‘Content-Type’: ‘application/json’},
body: JSON.stringify(
{
“personalizations”: [
{
“to”: [
{
“email”: “xxx@gmail.com
}
],
“subject”: “Hello, World!”
}
],
“from”: {
“email”: “from_address@example.com
},
“content”: [
{
“type”: “text/html”,
“value”: “

Hello, World!


}
]
})
})
.then(response => response.json())
.catch(error => console.log(‘error:’, error));

However, I keep on get the error message ‘TypeError: Failed To Fetch’.
I have tried to call the API using hurl.it and managed to call the web service successfully using the parameters used in the codes above.

I would really appreciate if anyone can give me pointers where did I go wrong.

Thank you.

Hey Alex,

Have you tried looking at this article: Velo Tutorial: Sending an Email on Form Submission | Help Center | Wix.com?

The article is fine but after following the tutorial i am still not able to send row updates or field submissions from user input elements that are attached to my database. I would pay for a module in the database module that i could connect to a selection of mail providers to transmit my form data. currently i use 123contact form but i cannot customise it enough to interact with individual pages on the website that are posting data to the same database.

Hi Russell,

I’m not sure what you mean by:

send row updates or field submissions from user input elements that are attached to my database
Could please elaborate?

i am creating a quote request form where users click on objects and type info which is registered in my database. i want to send the info every time that a submission is made to the sales email. using the tutorial that was given i cannot seem to find where to put the send grid email in order for it to work with the api and send the message.

1 Like

I’m trying to do the same thing, did you ever find a solution to this problem?