req.get(field)
This method returns the value of the header field.
Example
req.get('Content-Type');
index.js
'use strict' const express = require('express') const app = express() app.get('/', (req, res) => { var acceptContentType = req.get('Accept') var result = `acceptContentType : ${acceptContentType}` res.send(result) }) const port = 3000 app.listen(port, () => console.log(`Application started listening on port ${port}!`));
No comments:
Post a Comment