title: Constructing json response. NodeJS send empty response
body: <p>I have this code where I want to send a response containing data that I get by requesting the database multiple times. I don't understand why it sends an empty response.</p>
  
  <pre><code>var express = require('express'),
  router = express.Router(),
  database = require('../database');
  
  router.get('/', function(req, res, next){
  
    res.writeHead(200, {"Content-Type": "application/json"});
  
      var ttt;
      var yyy;
  
      database.getTagType().then(function(data) {
          ttt = "pfff";
      });
  
      database.getSpecie().then(function(data) {
          yyy = "akkhhh";
      });
  
    var json = JSON.stringify({
      anObject: ttt, 
      anArray: yyy, 
    });
    res.end(json);
  
  });
  
  module.exports = router;
  </code></pre>