I'm new to JavaScript and NodeJS, and I need to solve this issue quickly.
      connection(getSQL2)
    .then((table)=> {
        table.forEach(row=> {
            let obj = {
                countryid: row.IdPais,
                country: row.NombrePais
            };
            data.push(obj);
          });
        });
console.log(obj);
When I try to display the object using console.log, I get undefined, which seems pretty obvious. But what would be an easy way to get it to display the Object 'obj' that was created above?
UPDATE: Just to clarify, console.log is used here only as an example. I need to access the object from outside that function however I can.
Thanks in advance!
 
     
     
    