The app.get() function routes the HTTP GET Requests to the path which is being specified with the specified callback functions. Basically is it intended for binding the middleware to your application.
app.get( path, callback )
- path: It is the path for which the middleware function is being called.
- callback: They can be a middleware function or series/arrray of middleware functions.
Installation of express module:
- You can visit the link to Install express module. You can install this package by using this command.
npm install express
- After installing express module, you can check your express version in command prompt using the command.
npm version express
- After that, you can just create a folder and add a file for example, index.js. To run this file you need to run the following command.
Steps to run the program:
- The project structure will look like this:
- Make sure you have installed express module using following command:
npm install express
- Run index.js file using below command:
Server listening on PORT 3000
Now make GET request to http://localhost:3000/ and you will get the following output:
GET Request Called
- HTTP Request vs HapiJS Request in Node.js
- Scaffolding an ExpressJS app from scratch
- Routing Path for ExpressJS
- HandleBars Templating in ExpressJS
- Node.js | https.request() Function
- How to send a GET request from PHP?
- HTTP headers | Access-Control-Request-Headers
- Node.js | Request Module
- HTTP headers | Access-Control-Request-Method
- Simple POST request using the fetch API
- DELETE request using XMLHttpRequest by making Custom HTTP library
- Get request using AJAX by making Custom HTTP library
- POST request using AJAX by making Custom HTTP library
- How to make PUT request using XMLHttpRequest by making Custom HTTP library ?
- Simple GET and POST request using Fetch API method by making custom HTTP library
- How to make simple PUT request using fetch API by making custom HTTP library ?
- Simple DELETE request using fetch API by making custom HTTP library
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.