Parsing errors: unexpected token public/pages/c1dmp.js

I’m getting unexpected token (44.0) & (133.0) when parsing errors when I preview pages on my site. Can anybody explain what these errors are? I have not been able to figure it out.

My code is:

import wixCrm from 'wix-crm'; import wixWindow from 'wix-window';
$w.onReady(function () {
});
$w("#newsletterRecipients").onAfterSave( () => {
let firstName = $w("#newsletterFirstname").value;
let lastName = $w("#newsletterLastname").value;
let company = $w("#newsletterCompany").value;
let email = $w("#newsletterEmail").value;
let formused = $w("#formName1").text
wixCrm.createContact({
"newsletterFirstname": firstName,
"newsletterLastname": lastName,
"newsletterCompany": company,
"newsletteremail": email,
"formName1": formused
})
.then((contactId) => {
wixCrm.emailContact("newsletSignup", contactId, {
"variables": {
"subscriberFirstname": firstName,
"subscriberLastname": lastName,
"company": company
}
})
.then((result) => {
// popup Success message
popUpMessage("Success");
})
.catch((error) => {
// popup Error
popUpMessage(error);
});
});
function popUpMessage(message) {
wixWindow.openLightBox('Show Message', {'message':message});
}
}
import {sendEmail} from 'backend/email';
$w.onReady(function () {
$w("#newsletterRecipient").onAfterSave(sendFormData);
});
function sendFormData() {
const subject = `New Submission from ${$w("#newsletterCompany").value}`;
const body = `Name: ${$w("#newsletterFirstname").value}
\rLast Name: ${$w("#newsletterLastname").value}`;
sendEmail(subject, body)
.then(response => console.log(response));
}

Any advice would be appreciated.

It looks like you are mixing up two sets of code here.

The first one is for using a triggered email to a new contact after they have filled in a form, like I have on a site of mine with this code.

import wixCRM from 'wix-crm';

$w.onReady(function () {
  $w("#JoinUsForm").onAfterSave(() => {
    let startDate = $w("#startDate").value;
    let firstName = $w('#firstName').value;
    let lastName = $w('#lastName').value;
    let email = $w("#email").value;
    let choirRole = $w("#choirRole").value;
    let readMusic = $w("#readMusic").value;
    let choirBefore = $w("#choirBefore").value;
    let startNow = $w("#startNow").value;
    
    wixCRM.createContact({ 
        "firstName": firstName,
        "lastName": lastName,
        "emails": [email],
        "Choir Role": choirRole,
        "Read Music": readMusic,
        "Choir Before": choirBefore,
        "Start Now": startNow,
        "Start Date": startDate
      }) 
      .then((contactId) => { 
        return wixCRM.emailContact('joiningusform', contactId, { 
          "variables": { 
            "firstName": firstName,
            "email": email,
            "choirRole": choirRole,
            "readMusic": readMusic,
            "choirBefore": choirBefore,
            "startNow": startNow,
            "startDate": startDate.toLocaleDateString('en-GB', { weekday: 'short', day: 'numeric', month: 'short', year: 'numeric'})
          } 
        });  
      }) 
      .catch((err) => { 
        // handle the error if the email wasn't sent
        console.log(`Error: ${err}`);
      }); 
  }); 
}); 

Along with the second part being a section from the sending an email on form submission tutorial here.
https://support.wix.com/en/article/corvid-tutorial-sending-an-email-on-form-submission

This is an old yet still working example and there are newer versions available like this one which uses SendGrid REST API.
https://www.wix.com/corvid/forum/community-discussion/example-send-email-with-the-sendgrid-rest-interface

Or newer which uses SendGrid NPM through Wix Package Manager.
https://www.wix.com/corvid/forum/community-discussion/example-send-email-with-the-sendgrid-npm-interface

You can’t mix and match, you need to choose one or the other method here.

Also, all your imports should be together at the top of your page and you only need the one page onReady function.

@givemeawhisky Thank you for your very helpful reply! After reading through all the information, it’s not really clear whether or not something like a triggered email can be sent using the newer SendGrid NPM?
On form-submission, I still want the contact to be created, and an email (using a template I prepared) to be sent out. Assuming it can be done using a newer method, then I’m a bit lost as to how to implement it.

If you use triggered email, then you can make up the triggered email yourself.

If you use SendGrid, you will have to put up with how SendGrid sends out the email, unless you make up your own sending template.

You can see previous forum posts about it here.
https://www.wix.com/corvid/forum/community-discussion/how-to-design-my-email-notification
https://www.wix.com/corvid/forum/community-discussion/sending-template-emails-with-sendgrid-v3
https://www.wix.com/corvid/forum/community-discussion/sending-an-email-on-form-submission-using-sendgrid-template

Have a look at these pages from Vorbly and Nayeli Code Queen) too.
https://www.vorbly.com/Vorbly-Code/WIX-SENDGRID-API-V3—AUTO-EMAIL-MESSAGES
https://support.totallycodable.com/en/article/send-email-notification-using-sendgrid-npm-and-wix-code

Thank you GOS

'm having a little bit of trouble I created a lightbox using the right code but when I hit preview I get stuck at the bottom of the page, I tried scrolling up and down but it doesn’t budge, I tried switching pages but every time I hit preview I get sent back to the bottom of the page again.


this where I always get sent when i hit the preview button rand i tried deleting the codes but i still get sent back right.(this is the bottom of my page)

those are the codes for the lightbox.
Please help me I would truly appreciate it.