What is different between module.exports = testMethod ; and module.exports = { testMethod } ; Because when I am using module.exports = testMethod ; it is throwing error as below. Error: Route.get() requires a callback function but got a [object Undefined] But I am okay with module.exports = { testMethod } ;
Whole codes are
const testMethod = asyncErrorWrapper(async (req, res, next) => { const information = req.body; const question = await Question.create({ title: information.title, content: information.content, user: req.user.id, }); res.status(200).json({ success: true, data: question, }); }); module.exports = { testMethod }; https://stackoverflow.com/questions/65531868/module-exports-in-javascript January 02, 2021 at 01:15AM
没有评论:
发表评论