title: How to show health status of node server on HTML
body: <p>I have two servers. One is server1 running on port 8080 and another one is main app server which is running on 8081. Now i want to showcase the health status of server1 on UI(HTML) which is running on main app server(8081).I want to display the these elements on HTML.</p>
  
  <p>1.<code>Status code of server one.</code></p>
  
  <p>2.<code>Server is UP Or Down.</code></p>
  
  <p>3.<code>Response of the server one.</code></p>
  
  <p>This is my nodejs code.</p>
  
  <pre><code>const express = require('express');
  const http = require('http');
  const fs = require('fs');
  const bodyParser = require('body-parser');
  const router = express.Router();
  const path = require('path');
  const ejs = require('ejs');
  const app = express();
  const server1 = express();
  
  
  
  server1.get('/health', function (req, res, next) {
    res.json({health: true});
     res.status(200).end();
    });
  
  app.engine('html', require('ejs').renderFile);
  app.set('view engine', 'html');
  app.get('/', (req,res) =&gt; {
      res.render('index');
      console.log('server two')
    })
  
  server1.listen(8080);
  app.listen(8081);
  
  </code></pre>
  
  <p>Ajax part:</p>
  
  <pre><code>var xmlhttp = new XMLHttpRequest();
  
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4) {   
             if (xmlhttp.status == 200) {
                 document.getElementById("#demo1").innerHTML = xmlhttp.responseText;
             }
             else if (xmlhttp.status == 400) {
                alert('There was an error 400');
             }
             else {
                 document.getElementById('demo1').innerHTML = 'something else other than 200 was returned';
             }
          }
      };
  
      xmlhttp.open("GET", "http://localhost:8080/health", true);
      xmlhttp.send();
  </code></pre>
  
  <p>HTML:</p>
  
  <p><code>&lt;div id="demo1"&gt;&lt;/div&gt;</code></p>
  
  <p>What should i exactly do to display the health status of server1 on UI.</p>