【问题标题】:TypeError: callback is not a function this error occurTypeError:回调不是函数发生此错误
【发布时间】:2019-09-22 01:28:07
【问题描述】:

我收到一个错误 TypeError: callback is not a function

如何解决这个问题

在我的代码下面

router.post('/upload', upload.array('file',3), function (req, res, next) {
    var data = req.files;
    res.send(data);
    var docName = 'rabbit2';
    db.get(docName , function(err, body) {
        if (!err)
        {
            var doc = body;
            var docName = body._id;
            var docrev = body._rev;
            doc.service.push(data);
            db.insert(doc, docName, docrev, function (error, response) {
                if (!error) {
                    res.send(response);
                    console.log("response success",response);
                } else {
                    console.log("sad panda",error);
                }
            });
        }
    });
});

【问题讨论】:

    标签: node.js couchdb


    【解决方案1】:

    router.post 的正确调用是router.post(path, callback)。你有 upload.array('file',3) 回调应该在哪里。 Docs

    【讨论】:

      猜你喜欢
      • 2014-01-31
      • 2018-01-22
      • 2018-06-05
      • 2021-02-21
      • 1970-01-01
      • 2017-03-28
      • 2020-05-09
      • 2015-10-20
      相关资源
      最近更新 更多