title: Fetch api data from Node
body: <p>I have odbc connection to database on Node JS. </p>
  
  <pre><code>var express = require('express');
  var odbc = require('odbc');
  var app = express();
  var connectionString = 'Dsn=xxx;uid=xxx;pwd=xxx';
  
  
  app.get('/query/:table', function (req, res) {
      var table = req.params.table;
      //console.log('User is accessing : ' + table);
      var connection = odbc.connect(connectionString, (error, connection) =&gt; {
          connection.query("SELECT * FROM " + table + "", (error, result) =&gt; {
              if (error) { console.error(error) }
              var json = JSON.stringify(result);
              res.send(json);
  
      });
  });
  
  });
  
  app.get('/', function (req, res) {
      res.sendFile(__dirname + '/index.html');
  });
  app.listen(80, function () {
      console.log('Application listening on port 80');
  });
  
  </code></pre>
  
  <p>on localhost/query/colli my output is :</p>
  
  <p><em>[ { "MATRK1": "0000019863", "FLG1K1": "S" }, { "MATRK1": "0000019864", "FLG1K1": "S" }]</em> (and a lot of more rows)</p>
  
  <p>My index.html looks like this :</p>
  
  <pre><code>&lt;script src="https://code.jquery.com/jquery-3.4.1.slim.js"
          integrity="sha256-BTlTdQO9/fascB1drekrDVkaKd9PkwBymMlHOiG+qLI="
          crossorigin="anonymous"&gt;&lt;/script&gt;
  &lt;script&gt;
  function getElement(id) {
    return document.getElementById(id);
  }
  
      fetch('http://localhost/query/colli')
          .then(res =&gt; res.json())
          .then((res) =&gt; {
              const data = res;
              document.write(data)
              getElement('name').innerHTML = 'Name: ' + data;
          });
  &lt;/script&gt;
  &lt;div&gt;
      &lt;p id="name"&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;body&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>But i am receiving : </p>
  
  <p><em>[object Object],[object Object]</em> result</p>
  
  <p>What am i doing wrong please? I want to fetch data from Node into HTML.</p>
  
  <p>Thanks very much for your time :)</p>