title: Node.Js Retrieve specific data from SQL Server and encode it into JSON Array
body: <p>I know this question have many duplicates, but I have already wasted too much time searching for the right solution.</p>
  
  <p>First take a look at my Node.JS:</p>
  
  <pre><code>var express = require('express');
  var app = express();
  
  app.get('/', function (req, res) { 
      var sql = require("mssql");
  
      // config for your database
      var config = {
          user: 'myuser',
          password: 'mypass',
          server: 'myip', 
          database: 'mydatabase' 
      };
      sql.close();
      // connect to your database
      sql.connect(config, function (err) {
  
          if (err) console.log(err);
          var dataqu = '';
          // create Request object
          var request = new sql.Request();
  
          // query to the database and get the records
          request.query("select * from AR_Invoices", function (err, recordset) {
              if (err) console.log(err) 
              res.json(recordset);
              sql.close();
          }); 
      });
  });
  
  var server = app.listen(5000,'0.0.0.0', function () {
      console.log('Server is running..');
  });
  </code></pre>
  
  <p>This code runs fine, but the json result structure is like this :</p>
  
  <pre><code>{"recordsets":[[{"Tipe":"Invoices","InvoiceID":411891,"InvoiceNumber":"SR.1701.0001"}]],"recordset":[{"Tipe":"Invoices","InvoiceID":411891,"InvoiceNumber":"SR.1701.0001"}],"output":{},"rowsAffected":[1]}
  </code></pre>
  
  <p>I don't know why but for some reason the result is always resulting in duplicate.</p>
  
  <p>And how to just select <code>InvoiceID</code> and <code>InvoiceNumber</code> ?</p>
  
  <p>I already tested using <code>recordset.InvoiceID</code> or <code>recordset[0].InvoiceID</code> but all is always in vain, and the result always in duplicate.</p>
  
  <p>Can anyone explain how to do this properly?</p>
  
  <p>I want the final result became like this :</p>
  
  <pre><code>[
     { "InvoiceID":"1", "InvoiceNumber":"mynumber" }
  ]
  </code></pre>