Closed

Description
I'm sure I'm just misunderstanding something, but should this not work? Variables defined outside the pg.connect scope are not visible within it? I feel like I must be missing something obvious. Any little advice would be great. Thanks.
function(){ var myResultStore = []; pg.connect(conString, function(err, client) { if(err) throw new Error('Could not connect to the database'); client.query("SELECT name FROM people LIMIT 2", function(err, result) { if(err) throw new Error('Query Failure'); result.rows.forEach(function(row){ myResultStore.push(row.name)}); console.log(myResultStore.toString()); // ** correctly returns [Bob, John] }); } console.log(myResultStore); // ** returns [] }
Metadata
Metadata
Assignees
Labels
No labels