'app.get() function not getting called in node.js

So I am starting a node.js app, and familiarizing myself with the basics. I have installed express, and am using the get function to create a route and send a response. However, on entering the webpage on the browser, the page keeps loading and does not give a response. Any idea on what I am doing wrong here? Even the request body does not show up on the logs, so it looks like its not entering the get function.

Below is the code. Any help would be appreciated.

const http = require("http");
const express = require("express");
const bodyparser = require("body-parser");

const app = express();

const port = 3000;

app.get("/", (req, res) => {
console.log(req.body);
  res.send("XYZ Homepage");
});

app.listen(port, () => {
  console.log(`Listening on port ${port}`);
});


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source