错误被抛出,但错误响应对象在Mongoose中为空

我正在尝试向我的API发送请求。

我的代码是这样的

app.post('/api/create', (req, res, next) => { if (!req.headers || !req.headers.authorization) { return res.status(500).json({ status: 'error', err: 'No authorization header' }); } const bits = req.headers.authorization.split(' '); const scheme = bits[0]; const token = bits[1]; jwt.verify(token, 'secret', function(err, decoded) { if (!!err) { return res.status(400).json({ status: 'error', err: 'Invalid credentials.' }); } // const userId = decoded.id; // if (!userId) { return res.status(400).json({ status: 'error', err: 'User id missing', }); } // const { postId } = req.params; // User.findById(userId).then(user => { // if (!user) { return res.status(400).json({ status: 'error', err: 'User not found', }); } // Post.findById(postId).then(event => { // if (!post) { return res.status(400).json({ status: 'error', err: 'Post not found', }); } // ... }).catch(err => { // Could not find post return res.status(400).json({ status: 'error', msg: 'Could not find post', err }); }); }).catch(err => { // Could not find user return res.status(400).json({ status: 'error', msg: 'Could not find user', err }); }); }); }); 

但我收到对象的错误

 { status: 'error', msg: 'Could not find post', err: '' } 

err是完全空的。 我不知道如何debugging这个。 我正在捕捉错误}).catch(err => { ,所以我希望它写出错误,如果我到达catch()块。

什么会导致这个问题?