Thursday, 16 March 2017

How to get hostname on node js/express js without any request

My code is like this

var app = require('express')();
var http = require('http').Server(app);
var io = require('socket.io')(http);
var rq=require('request');
var url="http://localhost/ss/some.json";
var pages=Object();
rq(url, function (error, response, body) { 
  pages=JSON.parse(body);
});

here var url="http://localhost/ss/some.json";

i want to get "localhost" without sending any request

i tried

require("os").hostname();;

but this is returning machine name



via user3797053

No comments:

Post a Comment