I am using NodeJS. I am checking the response status of https://encrypted.google.com/ . I have a file in my project. Let's call it ,
status.js :-
var https = require('https');
https.get('https://encrypted.google.com/', function(res) {
console.log("statusCode: ", res.statusCode);
console.log("headers: ", res.headers);
res.on('data', function(d) {
process.stdout.write(d);
});
}).on('error', function(e) {
console.error(e);
});
Now, I also have server.js file and node is running through it.
node server.js
I want to execute the status.js till the nodeserver runs. That means, it should continously check the status of https://encrypted.google.com/. What is the recommended way to do this ?
server.js :-
const express = require('express');
const bodyParser = require('body-parser');
// create express app
const app = express();
// listen for requests
app.listen(3000, () => {
console.log("Server is listening on port 3000");
});