Last active
October 30, 2021 12:32
-
-
Save nhancv/28a97fae9daab89b31eb5c87778ee66d to your computer and use it in GitHub Desktop.
Get current lan ip address with nodejs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var address, ifaces = require('os').networkInterfaces() | |
| for (var dev in ifaces) { | |
| ifaces[dev].filter((details) => details.family === 'IPv4' && details.internal === false ? address = details.address : undefined) | |
| if(address) break | |
| } | |
| console.log(address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment