I´m quite new to ExpressJS, so i have a question about my Code.
router.post("/create", (req: Request, res: Response) => {
pruefungController.create(req, res);
});
public async create(req: Request, res: Response): Promise<void> {
const pruefung = new Pruefung({
fach: req.body.fach,
datum: req.body.datum,
raum: req.body.raum
});
await pruefung.save();
res.send(pruefung);
}
Is it enough to declare the create method as async or do i have to declare the callback also as async like this?
router.post("/create", async (req: Request, res: Response) => {
await pruefungController.create(req, res);
});
In my opinion it should be enough to just await the action of the .save() method, but i don´t know how Express handles the method passed into the router.post() method :(