Normally, everything works, but when there is no internet connection my app throws an error:
events.js:160
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND
/* my code - putting this to try...catch have no effect: */
var http = require('http');
// (...)
var req = http.request(options, response => {
/* ... */
});
req.write(data);
req.end();
So what can I do when internet connection shuts down and I would like to prevent my app from stopping?