Added catch block to main route
This commit is contained in:
@@ -17,6 +17,7 @@ router.post("/send", async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.post("/template/:template", async (req, res) => {
|
router.post("/template/:template", async (req, res) => {
|
||||||
|
try {
|
||||||
const { template } = req.params;
|
const { template } = req.params;
|
||||||
const { to, data } = req.body;
|
const { to, data } = req.body;
|
||||||
if (!to || !data) {
|
if (!to || !data) {
|
||||||
@@ -56,6 +57,10 @@ router.post("/template/:template", async (req, res) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
res.status(200).json({ message: "Email sent successfully" });
|
res.status(200).json({ message: "Email sent successfully" });
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error sending email:", error);
|
||||||
|
res.status(500).json({ error: "Failed to send email" });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
Reference in New Issue
Block a user