9951 explained code solutions for 126 technologies


nodejsHow to get IP address


const os = require('os');
const net = os.networkInterfaces();

let ip = net.eth0[0].address;ctrl + c
require('os')

module to work with OS

.networkInterfaces()

returns data on all network interfaces

net.eth0[0].address

returns first IP address of eth0 interface