I’m trying to use Wix to send a dynamic email template through SendGrid upon the user clicking a button, but I keep getting a couple of error messages and am wondering how I can fix these. The first error message I see is that there is an invalid character in the header, and the second error message I see is in Chrome Dev Tools, it shows that access is being blocked because of CORS. Here are my error messages and the code.

Page Code: I know for a fact all my variables are getting initialized and saved fine.
import {sendEmail} from 'backend/sendGrid2.jsw'
$w('#button8').onClick(async () => {
let result = sendEmail(body, parentEmail, firstName, logoLink2, level, impression, strengths, growthAreas, socialEmotionalClassReadiness, brochureLink, levelLink, classLink, siteAddress, sitePhone, siteEmail, facebook, linkedin, instagram, classTimings);
}
Backend:
sendGrid2.jsw
import {fetch} from 'wix-fetch';
import { sendEmailTemplate } from '@velo/sendgrid-templates-backend'
import wixSecretsBackend from 'wix-secrets-backend';
export async function sendEmail(body, parentEmail, firstName, lastName, logoLink2, level, impression, strengths, growthAreas, socialEmotionalClassReadiness, brochureLink, levelLink, classLink, siteAddress, sitePhone, siteEmail, facebook, linkedin, instagram, classTimings) {
const url = "https://api.sendgrid.com/v3/mail/send";
const sendGridSecret = JSON.parse(await wixSecretsBackend.getSecret('sendGridSecret'));
const key = sendGridSecret.key;
const senderEmail = sendGridSecret.senderEmail;
const MyHeaders = {
"Authorization": "Bearer " + key,
"content-type": "application/json"
};
const MyBody = {
"personalizations": [
{
"to": [
{
"email": parentEmail,
"name": firstName
}
],
"dynamic_template_data": [
{
"firstName": firstName,
"logoLink2": logoLink2,
"level": level,
"impression": impression,
"strengths": strengths,
"growthAreas": growthAreas,
"socialEmotionalClassReadiness": socialEmotionalClassReadiness,
"brochureLink": brochureLink,
"levelLink": levelLink,
"classLink": classLink,
"siteAddress": siteAddress,
"sitePhone": sitePhone,
"siteEmail": siteEmail,
"facebook": facebook,
"linkedin": linkedin,
"instagram": instagram,
"classTimings": classTimings
}
]
}
],
"from": {
"email": senderEmail,
"name": "Example Order Confirmation"
},
"subject": "Free Trial Assessment for " + firstName + " " + lastName,
"content": [
{
"type": "text/html",
"value": body
}
],
"template_id" : "d-3796a64d9b764b1db176cc8cbc348492"
};
sendEmailTemplate(MyBody);
}
How would I go about fixing these errors?