A module to verify if there's an active internet connection with Node.js
You can install this module through NPM using the following command in your terminal:
$ npm install internet-available --saveinternet-available requires Promises to work correctly. It's easy to use:
varinternetAvailable=require("internet-available");// Most easy wayinternetAvailable({// Provide maximum execution time for the verificationtimeout: 5000,// If it tries 5 times and it fails, then it will throw no internetretries: 5}).then(()=>{console.log("Internet available");}).catch(()=>{console.log("No internet");});But configurable too (check the docs).
The official documentation of the project can be found in Our Code World here.