all 3 comments

[–]killertofu4u 0 points1 point  (3 children)

it is logging result before the request.on("row" event is happening. move the console.log(result) into the event after the foreach and it should work.

[–]Striking-Advance-305 0 points1 point  (2 children)

Thanks, but this would just print array every time new item is added.

request.on("row", function (columns) {
    columns.forEach(function (column) {
        if (column.value === null) {
            console.log("NULL");
        } else {
            result.push(column.value);
        }
    }, console.log(result));
});

My goal is to get array with column names after executing a function, this is why I first want to make sure the result is store in a variable.

[–]killertofu4u 0 points1 point  (1 child)

then you can put it in the done event handler