I currently have this nodejs code to check if a website server is up or down:
var http = require("http");
http.get({host: "nodejs.org"}, function(res){
if( res.statusCode == 200 )
console.log("This site is up and running!");
else
console.log("This site is down " + res.statusCode);
});
Now, I want the program to ask the user to enter a website and then it will check if that website is up or down. I tried using the prompt method here:
var website = prompt("Please enter the website server you would like to check", "google.com");
However when I run this, I get this error:
ReferenceError: prompt is not defined
at Object.<anonymous> (/Users/navania/WebstormProjects/untitled/UpOrDown.js:3:15)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3).
I also tried using window.prompt as many other questions suggested, but that still gave me the same error except it says that window is not defined.
Any help would be appreciated. Thanks!