Response methods

This commit is contained in:
Zoheb Alli Khan 2021-06-04 11:41:30 +05:30
parent b995f9e2c4
commit 106d656567
1 changed files with 35 additions and 1 deletions

View File

@ -163,9 +163,22 @@ app.use('<admin dir>', admin)`; // Mounting a sub - app
```Request```
``Methods``
`req.param('name')`
`req.get('content-type')`
`req.accepts('html')`
`req.is('json')`
`var range = req.range(1000)
if (range.type === 'bytes'){
range.forEach(function(r){
})
}`
``Properties``
`req.param('name')`
`app.post('/', function (req, res, next) {
console.log(req.body)
@ -181,3 +194,24 @@ res.send('GET')`
`console.dir(req.signedCookies.user)`
```Response```
``Methods``
`res.redirect('https://google.com')`
`res.send({message: 'Awesome Stuffs'})`
`res.json({alert: 'awesomecheatsheets'})`
`const file = req.params.name;
res.sendFile(file, options, function(err){
if(err){
next(err)
}else{
console.log('Sent:', file)
}
})`
`res.render('index')`