Skip to content

Commit

Permalink
Update contact.controller.js
Browse files Browse the repository at this point in the history
  • Loading branch information
PriyanshuValiya authored Oct 24, 2024
1 parent 1f8f7e3 commit c9bf8af
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions backend/controller/contact.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,23 @@ const createContactUs = async (req, res) => {
text: message,
};

// Send mail with defined transport object
transporter.sendMail(mailOptions, (error, mailOptions) => {
if (error) {
return console.error("Error occurred: " + error.message);
}
// Send mail with defined transport object

+ await new Promise((resolve, reject) => {
+ transporter.sendMail(mailOptions, (error, info) => {
+ if (error) {
+ console.error("Error occurred: " + error.message);
+ reject(error);
+ }
+ resolve(info);
+ });
+ });
+
+ res.status(200).json({
+ status: "success",
+ message: "Your contact request has been successfully received.",
+ });

});

res.status(200).json({
status: "success",
message: "Your contact request has been successfully received.",
});
} catch (err) {
console.error(`Error at transport: ${err}`);
res.status(500).json({
Expand Down

0 comments on commit c9bf8af

Please sign in to comment.