mirror of
https://github.com/typicode/json-server.git
synced 2025-07-28 12:43:18 +08:00
Merge branch 'patch-1' of https://github.com/gberger42/json-server into gberger42-patch-1
Conflicts: README.md
This commit is contained in:
24
README.md
24
README.md
@ -15,9 +15,9 @@ Created with :heart: for front-end developers who need a flexible back-end for q
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ cat db.json
|
$ cat db.json
|
||||||
{
|
{
|
||||||
posts: [
|
"posts": [
|
||||||
{ id: 1, body: 'foo' }
|
{ "id": 1, "body": "foo" }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
$ json-server --file db.json
|
$ json-server --file db.json
|
||||||
@ -32,9 +32,9 @@ file.
|
|||||||
```javascript
|
```javascript
|
||||||
var server = require('json-server');
|
var server = require('json-server');
|
||||||
|
|
||||||
var db = {
|
var db = {
|
||||||
posts: [
|
posts: [
|
||||||
{id: 1, body: 'foo'}
|
{ id: 1, body: 'foo' }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,13 +100,13 @@ Here's 2 examples showing how to format JSON or JS seed file:
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
{
|
{
|
||||||
posts: [
|
"posts": [
|
||||||
{ id: 1, body: 'foo'},
|
{ "id": 1, "body": "foo" },
|
||||||
{ id: 2, body: 'bar'}
|
{ "id": 2, "body": "bar" }
|
||||||
],
|
],
|
||||||
comments: [
|
"comments": [
|
||||||
{ id: 1, body: 'baz', postId: 1}
|
{ "id": 1, "body": "baz", "postId": 1 }
|
||||||
{ id: 2, body: 'qux', postId: 2}
|
{ "id": 2, "body": "qux", "postId": 2 }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@ -118,7 +118,7 @@ exports.run = function() {
|
|||||||
var data = {};
|
var data = {};
|
||||||
|
|
||||||
data.posts = [];
|
data.posts = [];
|
||||||
data.posts.push({id: 1, body: 'foo'});
|
data.posts.push({ id: 1, body: 'foo' });
|
||||||
//...
|
//...
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
Reference in New Issue
Block a user