I am trying to test a simple javascript file but unable to test as on my browser the page loads for forever without any warnings and at the bottom side a text bar appears saying "waiting for localhost..." On bash, I'm typing node app.js and after hitting enter terminal says "Server Has Started" as expected but when I go to "http://localhost:3000" the page keeps on loading forever. I've Installed node and express rightly. (I was not able to include express here as I don't know how to.) Please be nice, I am new to the world of development.
// Express Setup
let express = require("express");
let app = express();
// Setting Up Routes
app.get("/",function(req,res) {
res.send = "Hi There, Welcome To My Assignement!";
});
app.get("/:actionName/pig", function(req , res){
res.send = "The Pig Says \"Oink\" !";
});
app.get("/:actionName/dog", function(req , res){
res.send = "The Dog Says \"Woof\" !";
});
app.get("/:actionName/cow", function(req , res){
res.send = "The cow Says \"Moo\" !";
});
app.get("/repeat/:string/:times",function(req,res){
let times = parseInt(app.param.times);
for (let i = 0 ; i <= times ; i++) {
res.send = app.param.toString;
}
});
app.get("*" , function(req,res){
res.send = "Error 404, Page not found!";
});
// Setting Port Up
app.listen(3000, function () {
console.log("Server Has Started!");
});
res.send("content")otherwise you are overwriting the 'send' function, and express will not return any result.