TypeError: $w(...).onBeforeSave is not a function

I’m trying to follow Wix’s instructions for sending an email to yourself via SendGrid upon form submit found here:

I’m able to successfully submit form data and save to the database, but I can’t ever seem to get SendGrid to trigger.

Error message I get in console after form submit:
wixcode-worker.js:17 TypeError: $w(…).onBeforeSave is not a function
t.(anonymous function) @ wixcode-worker.js:17

My Page Code:
import {sendEmail} from ‘backend/email’;

$w.onReady( function () {

function sendFormData() {
const subject = Test Email;
const body = Name:;

sendEmail(subject, body)
.then(response => console.log(response));

The back-end stuff is a direct copy and paste from the Wix article with the key, sender, and recipient constants updated with the correct info.
The “Quote_Request” is the right database and the capitalization is correct.


UPDATE: I figured out my mistake. I was entering the database name in the $w(" #Quote_Request ").onAfterSave(sendFormData); function but I should have been entering the name that appears after the # when you hover over the database in the Wix editor.