I’m using a custom form - simple form for collecting user input and then submitting to a database and then to send the form data by email to me (plus another)
All seems to be OK in the the web modules (using sendGrid etc) but the .then … at the end of this code is causing error - can anyone help. I’m very new to Java so can’t see a solution easily.
import { sendEmail , sendEmailWithRecipient } from ‘backend/email’ ;
function sendFormData () { const subject = Type Your Subject Here ${ $w ( "#input1" ). value } ; const body = Type Here: ${ $w ( "#input1" ). value } \rLabelHere: ${ $w ( "#input11" ). value } \rLabelHere: ${ $w ( "#input11" ). value } \rLabelHere: ${ $w ( "#input11" ). value } \rLabelHere: ${ $w ( "#input11" ). value } \rLabelHere: ${ $w ( "#input11" ). value } \rLabelHere: ${ $w ( "#input11" ). value } \rLabelHere: ${ $w ( "#input11" ). value } ; const recipient = $w ( “#input11” ). value ;
sendEmailWithRecipient ( subject , body , recipient )
. then ( response => console . log ( response )); (ERROR on this line)
sendEmail ( subject , body )
. then ( response => console . log ( response )); (ERROR on this line)
}
I haven’t changed the subject or body headings nor the labels yet as I wanted to see if this worked before editing etc. I simply copied this code from wix help and checked with similar scenarios on the web.
I can’t really tell what’s going on since both backend emails are not provided in this post, there is probably an error on at least one of them that returns an error.
Also, the screenshot of the error is not that useful; as we cannot see the whole error object, you should expand them all before taking the screenshot.
Please update the post and we’ll take another look into it.
It seems like it is from the Velo example, have you connect your own keys? Different sendgrid account has different key. You cannot use it without keys
OK thanks - I did change the import line and it didn’t work.
I note your comments however the problem I have is that having seen several videos re Wix script on the subject and having essentially the same input fields on the user form and using the code for the modules and page code (amended where required), it seems to work on the video’s but not when using my form. Not sure I’m understanding where the differences are especially given there are no err msgs showing when running the code. I will continue to research etc.