I have a Node.js app. I am trying to detect connectivity. I know how to check to see if I can reach the internet by pinging Google. However, I'm curious if there's a way to check to see if I'm connected to a network (i.e. a router) before checking to see if I can access the outside world.
Is there a way I can check to see if I'm connected to a network, but not necessarily get to the outside world? If so, how?
I know in JavaScript, I could check the navigator.onLine
property. However, the navigator
property doesn't exist in Node.