NodeJS_0006:nodejs响应超时处理

1,

    // 获取参数设置
    app.get('/getPara', function(req, res) {
        // console.log(req.hostname);
        // console.log(req.params);
        // console.log(req.path);
        console.log(req.query);
        // http://localhost:81/getPara?id=3&name=wg
        JSONCRUD.findOne(req.query.id, function(err, data) {
            if (err) {
                return res.json({ "error": "error" });
            }
            res.json({
                'val': data
            });
        });
        // 响应超时处理
        res.setTimeout(3000, function() {
            res.json({ "error": "error" });
        });
    });
琥珀君的博客
原文地址:https://www.cnblogs.com/eliteboy/p/13278401.html