async / await [ TIL ] [ node.js ]
Problem express 를 이용하여 간단한 게시판 api 를 만들던중 undefined 가 발생했다. Try router.post("/", async (req, res) => { console.log(req.body); try { const { title, content, userId } = postCreateValidation.validateAsync( req.body ); console.log(title, content, userId); const post = await Post.create({ title, content, userId, }); res.json(post); } catch (err) { if (err.isJoi) { return res.status(422).json({ messa..
2023.06.22