【问题标题】:SQL query results in UnhandledPromiseRejectionWarning: ReferenceError: response is not definedSQL 查询导致 UnhandledPromiseRejectionWarning: ReferenceError: response is not defined
【发布时间】:2019-06-01 15:52:54
【问题描述】:

我正在尝试使用此代码从 mysql 中的表中显示特定数据。我在使用 for 循环之间,但它说 resresponse 没有定义。我需要在下面的代码中编辑或更改什么?

function lowInventory() {
    console.log("View all product that are low in inventory...\n");
    for (var i = 0; i < response.length; i++) {
        connection.query("SELECT stock_quantity (*) FROM products WHERE stock_quantity < 5", function (err, res) {
            if (err) throw err;
            //log all results of the SELECT statement
            console.table(Response);
            connection.end();
        });
    }
}

我需要它在我的表中显示 node.js 中数量小于 5 的结果。

【问题讨论】:

    标签: mysql sql node.js


    【解决方案1】:

    将 console.table(Response) 更改为 console.log(Response)

    【讨论】:

      猜你喜欢
      • 2019-11-10
      • 1970-01-01
      • 2020-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-04
      相关资源
      最近更新 更多