mirror of
https://github.com/typicode/json-server.git
synced 2025-08-01 06:34:02 +08:00
Update README.md
This commit is contained in:
11
README.md
11
README.md
@ -133,20 +133,15 @@ You can use JSON Server as a module:
|
||||
```javascript
|
||||
var jsonServer = require('json-server')
|
||||
|
||||
var object = {
|
||||
posts: [
|
||||
{ id: 1, body: 'foo' }
|
||||
]
|
||||
}
|
||||
|
||||
var server = jsonServer.create() // Express server
|
||||
|
||||
server.use(jsonServer.defaults) // Default middlewares (logger, public, cors)
|
||||
server.use(jsonServer.router(object)) // Express router
|
||||
server.use(jsonServer.router('db.json')) // Express router
|
||||
|
||||
server.listen(3000)
|
||||
```
|
||||
|
||||
For an in-memory database, you can pass an object to `jsonServer.route()`.
|
||||
|
||||
### Deployment
|
||||
|
||||
You can deploy JSON Server. For example, [JSONPlaceholder](http://jsonplaceholder.typicode.com) is an online fake API powered by JSON Server and running on Heroku.
|
||||
|
Reference in New Issue
Block a user