This is the code I am working on:
methods: {
async pay() {
this.$notify(`working`);
if (!this.$v.$invalid) {
try {
var data = {
to: this.to,
subject: this.subject,
};
let response = await axios
.post("http://localhost:4000/api/blogs", data)
.then(() => {
this.$notify(`email has been sent`);
})
.catch(error => {
const message = error.response.data.message;
this.$notify("Oh oo!", `${message}`, "error");
});
} catch (err) {
console.log(err);
}
}
}
}
I'm attempting to show the message "email has been sent" as soon as the email is successfully sent. However, it's not working even if I try using console.log or alert in the function within .then block.
When I execute the function, I see "working" notification first before the actual email sent notification.
Can anyone please suggest how can I achieve the desired behavior?