Welcome aboard! We are happy you are here and wish you good net-raft!
// code below insert into getip.js
var http = require('http');
const request = require('request')
var srv = http.createServer(function (req, res) {
request('http://ipinfo.io', function(error, res1, body) {
var ipuser = JSON.parse(body)
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(ipuser.ip);
})
});
srv.listen(3000);
console.log("Listening to Port 3000");
// type "node getip.js" in command prompt
// then put this url "http://localhost:3000/" into any browser
const request = require('request')
var srv = http.createServer(function (req, res) {
request('http://ipinfo.io', function(error, res1, body) {
var ipuser = JSON.parse(body)
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(ipuser.ip);
})
});
srv.listen(3000);
console.log("Listening to Port 3000");
The most helpful NODEJS solutions
get user ipNODEJS Click to see more ... 7.8K 1.7K