Testing Basic GET request

It is used to Handle a basic GET request in Express. One of the main reasons for its wide use is because of its simple and straightforward behaviour.

Syntax:

app.get('/', (req, res) => {
res.send('Hello, this is a basic GET request!');
});

Example: In this example we will see the Basic GET request

Javascript




const express = require("express");
const app = express();
let port = 8080;
 
app.listen(port, () => {
    console.log(`server is running on port ${port}`);
});
 
app.get("/", (req, res) => {
    res.send("your request is successful");
});


Output:

Output

How to test GET Method of express with Postman ?

The GET method is mainly used on the client side to send a request to a specified server to get certain data or resources. By using this GET method we can only access data but can’t change it, we are not allowed to edit or completely change the data. It is widely one of the most used methods. In this article, you are going to learn how to use the GET Method in Express. This article will cover syntax and examples to help you use this method.

Similar Reads

Prerequisites:

Basic knowledge of Node and Express. npm(node package manager) Basics of Postman....

1. Testing Basic GET request:

It is used to Handle a basic GET request in Express. One of the main reasons for its wide use is because of its simple and straightforward behaviour....

2. Testing GET Request with Route Parameters:

...