@givemeawhisky Sorry, I didn’t include all of my code. I am still using the Wix Location API and republishing my site each time I update the code.
Here is the full page code:
import wixLocation from 'wix-location';
// ...
wixLocation.onChange( (location) => {
let newPath = location.path;
} );
$w.onReady(function () {
$w("#dataset2").onBeforeSave(function() {
$w("#dataset2").setFieldValue('pageUrl', wixLocation.url);
});
});
import {sendEmail} from 'backend/email';
$w.onReady(function () {
$w("#dataset2").onAfterSave(sendFormData);
});
async function sendFormData() {
const subject = `New Submission from ${$w("#input9").value}`;
let path = await wixLocation.onChange((location) => {
return wixLocation.url;
})
const body = `First Name: ${$w("#input1").value}
\rLast Name: ${$w("#input2").value}
\rEmail: ${$w("#input4").value}
\rPhone: ${$w("#input3").value}
\rPosition/Title: ${$w("#input6").value}
\rCompany: ${$w("#input5").value}
\rHow did you hear about us?: ${$w("#input7").value}
\rIndustry/Application: ${$w("#input8").value}
\rProduct Interest: ${$w("#input9").value}
\rComments: ${$w("#input10").value}
\rURL: path`;
sendEmail(subject, body)
.then(response => console.log(response));
}