Skip to content

Commit

Permalink
documentation for sendStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydaly committed Dec 26, 2018
1 parent 2990ada commit 01a59e9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Whatever you decide is best for your use case, **Lambda API** is there to suppor
- [removeHeader()](#removeheaderkey)
- [send()](#sendbody)
- [sendFile()](#sendfilefile--options--callback)
- [sendStatus()](#sendstatuscode)
- [status()](#statuscode)
- [type()](#typetype)
- [Enabling Binary Support](#enabling-binary-support)
Expand Down Expand Up @@ -430,6 +431,17 @@ api.get('/users', (req,res) => {
})
```

### sendStatus(code)
The `sendStatus` method sets the status code and returns its string representation as the response body. The `sendStatus()` method accepts a single integer argument.

```javascript
res.sendStatus(200) // equivalent to res.status(200).send('OK')
res.sendStatus(304) // equivalent to res.status(304).send('Not Modified')
res.sendStatus(403) // equivalent to res.status(403).send('Forbidden')
```

**NOTE:** If an unsupported status code is send, it will return 'Unknown' as the body.

### header(key, value [,append])
The `header` method allows for you to set additional headers to return to the client. By default, just the `content-type` header is sent with `application/json` as the value. Headers can be added or overwritten by calling the `header()` method with two string arguments. The first is the name of the header and then second is the value. You can utilize multi-value headers by specifying an array with multiple values as the `value`, or you can use an optional third boolean parameter and append multiple headers.

Expand Down

0 comments on commit 01a59e9

Please sign in to comment.