I have a pretty straight forward triggered email as shown below. When the email is sent I get the following error "TypeError: Preflight response is not successful. Below is the snippet of code. Here’s my log trace:
Loading the code for the Contacts page. To debug this code, open i6kjt.js in Developer Tools.
Log output:
create contact.
Done
contact created.
contactId : eb3d37ab-5d92-4d8a-b238-4d4e8c321fa6
Sending emailContact
TypeError: Preflight response is not successful
Code below:
// For full API documentation, including code examples, visit Velo API Reference - Wix.com
import wixCRM from ‘wix-crm’ ;
$w.onReady( function () {
})
export function button1_click(event) {
// Add your code for this event here:
// TODO: write your page related code here…
console.log( “create contact.” );
wixCRM.createContact({
“firstName” : $w( ‘#firstName’ ).value,
“lastName” : $w( ‘#lastName’ ).value,
“email” : $w( “#email” ).value,
“phone” : $w( ‘#phone’ ).value,
“message” : $w( ‘#message’ ).value
})
.then((contactId) => {
console.log( “contact created.” );
console.log( "contactId : " + contactId);
console.log( “Sending emailContact” );
wixCRM.emailContact( ‘[MY CODE]’ , contactId, {
variables: {
firstName: $w( ‘#firstName’ ).value
}})
.then(() => {
console.log( “email sent to contactId” );
// do something after the email was sent
})
. catch ((err) => {
console.log(err);
});
})
. catch ( (err) => {
console.log(err);
})
console.log( “Done” );
}