@levihub/getnetworks
v1.0.2
Published
Easy tool for getting networks (based on 'os' package).
Downloads
2
Readme
Installation
npm i @levihub/getnetworks
Usage/Examples
Import the function
const getNetworks = require('getnetworks');
// or
import getNetworks from 'getNetworks';
Call the function
let networks = getNetworks(); // returns an array
console.log(networks); // [ '192.168.0.55', 'localhost' ] for example
Usage when running web servers
You can use it whenever you are running a web server.
const runningOn = ['Server running on:'];
getnetworks().forEach(IP => runningOn.push(`'http://${IP}:${PORT}'`));
console.log(runningOn.join(' '));
// This could be the output from the console log:
// Server running on: 'http://192.168.0.55:8080' 'http://localhost:8080'