Hello,
I have implemented EmailJS for a contact form. I also use vue.js, but my questions is more directly JS related (not vue specific and/or EmailJS specific)
I have implemented EmailJS for a contact form. I also use vue.js, but my questions is more directly JS related (not vue specific and/or EmailJS specific)
I send an Email with the EmailJS function send. Everything works fine. (EmailJS works fine, vue works fine no problems here!!) I use a promise fo the http request.
I have a little problem here. I can empty the fields with e.target.reset() at the end of the promise. Right now I have the reset outside the handlers. So the data is sent -> the fieds are emptied, the messages comes back, now the fields are filled again!!
I guess I should bring e.target.reset() somehow into the .then or .catch block?
How could I handle this, that the fields stay empty?
methods: {
sendEmail(e) {
const emailParams = {
uname: this.uname,
email: this.email,
message: this.message
};
emailjs.send('service_1234','template_1234', emailParams, 'user_1234')
.then((result) => {
this.successHttpMsg = true;
console.log('SUCCESS!', result.status,result);
}).catch((e) => {
this.error = e;
this.errorHttpMsg = true;
console.log("Caught",this.error);
});
e.target.reset();
},
Code (JavaScript):
Thanks a lot guys!