mirror of
https://github.com/LeCoupa/awesome-cheatsheets.git
synced 2025-11-08 14:01:35 +00:00
Response methods
This commit is contained in:
@@ -163,9 +163,22 @@ app.use('<admin dir>', admin)`; // Mounting a sub - app
|
|||||||
```Request```
|
```Request```
|
||||||
``Methods``
|
``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``
|
``Properties``
|
||||||
|
|
||||||
|
`req.param('name')`
|
||||||
|
|
||||||
`app.post('/', function (req, res, next) {
|
`app.post('/', function (req, res, next) {
|
||||||
console.log(req.body)
|
console.log(req.body)
|
||||||
@@ -181,3 +194,24 @@ res.send('GET')`
|
|||||||
|
|
||||||
`console.dir(req.signedCookies.user)`
|
`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')`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user