Get the state of NetworkManager. Get notifications when the state changes, i.e. when your computer gets connected and disconnected from the Internet.
npm install nm-state
var nmState =
Code and state may be one of the following:
0: 'unknown' 10: 'asleep' 20: 'disconnected' 30: 'disconnecting' 40: 'connecting' 50: 'connected_local' 60: 'connected_site' 70: 'connected_global'