Nodejs声明或语句预期

时间:2017-10-29 03:49:56

标签: node.js

我正在尝试查找此代码的错误,但我无法找到它 声明或声明预期错误

function deleteFromGame() {
    for (var k in removefromGame) {
        if (removefromGame[k]['expire'] - time() <= 0) {
            pool.query('SELECT trade_token FROM games WHERE id= ' + pool.escape(removefromGame[k]['id']), function(err, row) {
                if (err)
                    throw err;
                if (row.length == 0)
                    return;

                if (row[0].trade_token == '') {
                    var offer = removefromGame[k]['offer'];
                    offer.decline((err)=>{
                        if (err)
                            return;
                        pool.query('UPDATE games SET psteamid = "", pname = "", pavatar = "", pskinsurl = "", pskinsnames = "", pskinsprices = "", ptp = "", passetids = "", trade_token = "" WHERE id = ' + pool.escape(removefromGame[k]['id']), function(er, ro) {});

                        loadAllGames();
                        sendGames(removefromGame[k]['id']);

                    }
                    );
                }
            });
        }

    }

}

你能帮我解决这个问题吗,对我来说是个头疼的问题

1 个答案:

答案 0 :(得分:1)

您应该为代码使用任何代码样式,并使用tabspace

我编辑了您的代码:

function deleteFromGame() {
    for (var k in removefromGame) {
        if (removefromGame[k]['expire'] - time() <= 0) {
            pool.query('SELECT trade_token FROM games WHERE id= ' + pool.escape(removefromGame[k]['id']), function(err, row) {
                if (err)
                    throw err;
                if (row.length == 0)
                    return;

                if (row[0].trade_token == '') {
                    var offer = removefromGame[k]['offer'];
                    offer.decline((err)=>{
                        if (err)
                            return;
                        pool.query('UPDATE games SET psteamid = "", pname = "", pavatar = "", pskinsurl = "", pskinsnames = "", pskinsprices = "", ptp = "", passetids = "", trade_token = "" WHERE id = ' + pool.escape(removefromGame[k]['id']), function(er, ro) {});

                        loadAllGames();
                        sendGames(removefromGame[k]['id']);
                    });
                }
            });
        }

    }
}