node js api返回响应twise

时间:2018-03-26 09:43:40

标签: node.js

你是节点js api的新手

我的程序返回数据,如下所示 我不知道我犯了什么错误

它只是从mssql数据库返回表中的所有行。

记录集&记录

exports.getList = function (req, resp) {
    db.executeSql("SELECT * FROM OfficeDetails", function (data,err) {
        if (err) {
            httpMsgs.show500(req, resp, err);
        } else {
            console.log("response data " + JSON.stringify(data));
            httpMsgs.sendJson(req, resp, data);
           }
    });
};

{
    "recordsets": [
        [
            {
                "DeptName": "Software",
                "DeptId": 3
            },
            {
                "DeptName": "Sales",
                "DeptId": 1
            }
        ]
    ],
    "recordset": [
        {
            "DeptName": "Software",
            "DeptId": 3
        },
        {
            "DeptName": "Sales",
            "DeptId": 1
        }
    ],
    "output": {},
    "rowsAffected": [
        2
    ]
}

1 个答案:

答案 0 :(得分:0)

exports.getList = function (req, resp) {
    db.executeSql("SELECT * FROM OfficeDetails GROUP BY DeptId HAVING COUNT(DeptId )>1", function (data,err) {
        if (err) {
            httpMsgs.show500(req, resp, err);
        } else {
            console.log("response data " + JSON.stringify(data));
            httpMsgs.sendJson(req, resp, data);
           }
    });
};
试试这个