-1
global.games = {};

let sql = /* some Sql */;
connection.query(sql, function(err, results) {
   /* results must be parsed and stored in global.games, but I can see them only inside this function*/

});

How can I get the results outside callback?

CroMagnon
  • 1,218
  • 7
  • 20
  • 32

1 Answers1

0

You can add response object to JavaScript global object window

window.global.games = {};

let sql = /* some Sql */;
connection.query(sql, function(err, results) {
    window.global.games = results;
});
CroMagnon
  • 1,218
  • 7
  • 20
  • 32