req.acceptsCharsets(charset
[, ...])
It returns the first accepted charset of the specified
character sets. It uses Accept-Charset header.
If no charset matches, then it return false.
Example
var temp = req.acceptsCharsets('utf-8', 'iso-8859-1')
index.js
const express = require('express') var cookieParser = require('cookie-parser') const app = express() app.use(cookieParser()); app.get('/', (req, res) => { var temp = req.acceptsCharsets('utf-8', 'iso-8859-1') if(temp){ var responseData = ('Client accepts ' + temp) } res.send(responseData) }) const port = 3000 app.listen(port, () => console.log(`Application started listening on port ${port}!`));
Run index.js
Open the url ‘http://localhost:3000/’ in browser, you can
see below kind of response.
No comments:
Post a Comment