JavaScript Async series with node-mysql output to array async series with promises,async series with arguments,async series

I would like to store result from mysql query in an array ( docAutocomplete) and after all the query completed I wanted to see the final array. I am using async series for this purpose. The issue is the array doesn't print anything as it looks like doesn't have any data at the function(err,results).

var mysql = require('mysql'),
async = require("async");
var connection = mysql.createConnection({
host: 'xx',
user: 'xx',
password: 'xx',
database: 'xx'
multipleStatements: true
});
var docAutocomplete = [];

async.series([

    function(callback) {
        connection.connect();


        connection.query('select x from a; select b from a', function(err, rows, fields) {
            if (err) throw err;

            for (var i = 0; i < rows[0].length; i++) {

                docAutocomplete.push({
                    " First Name": rows[0][i].x


                })
            }
            for (var i; i < rows[1].length; i++) {

                docAutocomplete.push({
                    "Last Name": rows[1][i].b

                })
            }





        });
        callback(null, 'one');

    },
    function(callback) {

        connection.end();

        callback(null, 'two');
    }
],
function(err, results) {
    console.log(results);
    console.log(JSON.stringify(docAutocomplete));

});

Current output is something like below;

[ 'one', 'two' ]
[]  // value of docAutocomplete array. Should have something here First Name and  Last name
Answer:1

I am using a off canvas menu similar to the one on W3 Schools by having two functions called to toggle the menu on/off using onclick. I am wanting to add in a function to be able to close the menu by ...

I am using a off canvas menu similar to the one on W3 Schools by having two functions called to toggle the menu on/off using onclick. I am wanting to add in a function to be able to close the menu by ...

I have AWS Cognito installed for my Angular application, and I am trying to hook in the s3.putObject some how into the ng-file-upload Upload service. I want to use ng-file-upload's Upload.upload() ...

I have AWS Cognito installed for my Angular application, and I am trying to hook in the s3.putObject some how into the ng-file-upload Upload service. I want to use ng-file-upload's Upload.upload() ...

  1. upload file using ajax
  2. upload file using retrofit android example
  3. upload file using javascript
  4. upload file using postman
  5. upload file using jquery
  6. upload file using ajax in php example
  7. upload file using php
  8. upload file using curl
  9. upload file using ajax php
  10. upload file using json
  11. upload file using python script
  12. upload file using ssh
  13. upload file using selenium
  14. upload file using ajax jquery
  15. upload file using putty
  16. upload file using curl command line
  17. upload file using httpwebrequest c#
  18. upload file using volley android
  19. upload file using web api c#
  20. upload file using javascript ajax

I want to know if it is more correct to use innerHTML: function createModal(){ modal = document.createElement('div'); modal.id = "modal"; modal.className = "modal"; modal.innerHTML = "<...

I want to know if it is more correct to use innerHTML: function createModal(){ modal = document.createElement('div'); modal.id = "modal"; modal.className = "modal"; modal.innerHTML = "<...

  1. append getelementbyid innerhtml
  2. element append innerhtml
  3. jquery append element innerhtml

I have a working graph which displays some nodes & their attributes. Then I get a JSON with different data, where some nodes may already exist on my graph. How to combine both data sources, to ...

I have a working graph which displays some nodes & their attributes. Then I get a JSON with different data, where some nodes may already exist on my graph. How to combine both data sources, to ...