Can anyone show me why my codes not working. I hereby paste
with my email.jsw, sendGrid.js and Event hander
import {sendWithService} from ‘backend/sendGrid’;
export function sendEmail(subject, body) {
const key = “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”;
const sender = “from.hl@framecount.com”;
const recipient = “to.datacollection@mascusa.com”;
return sendWithService(key, sender, recipient, subject, body);
}
export function sendEmailWithRecipient(subject, body, recipient) {
const key = “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”;
const sender = “from.hl@framecount.com”;
return sendWithService(key, sender, recipient, subject, body);
}
##################################################################
import {fetch} from ‘wix-fetch’;
export function sendWithService(key, sender, recipient, subject, body) {
const url = “https://api.sendgrid.com/api/mail.send.json”;
const headers = {
“Authorization”: "Bearer " + key,
“Content-Type”: “application/x-www-form-urlencoded”
};
const data = from =${sender}&to=${recipient}&subject=${subject}&text=${body}
;
const request = {
“method”: “post”,
“headers”: headers,
“body”: data
};
return fetch(url, request)
.then(response => response.json());
}
######################################################################
import {sendEmail, sendEmailWithRecipient} from ‘backend/email’;
$w.onReady( function () {
$w(“#dataset8”).onAfterSave(sendFormData);
});
function sendFormData() {
const subject = Membership Application From ${$w("#input1").value}
;
const body = Name: ${$w("#input1").value} \rWhat Application: ${$w("#dropdown1").value} \rWhich Member: ${$w("#radioGroup1").value} \rEmail: ${$w("#input9").value}
;
const recipient = $w(“#input9”).value;
sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));
}