req.method
Specifies the http method (GET, POST, PUT, HEAD etc.,) of
the request.
index.js
const express = require('express') var cookieParser = require('cookie-parser') const app = express() app.use(cookieParser()); app.get('/', (req, res) => res.send("Hello World")) app.all('/users', (req,res) => { res.send(`Received ${req.method} kind of request`) }) const port = 3000 app.listen(port, () => console.log(`Application started listening on port ${port}!`));
Run index.js
Open the url ‘http://localhost:3000/users’ in browser,
you will see below kind of response.
No comments:
Post a Comment