File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change 2
2
3
3
[ ![ Node.js CI] ( https://github.com/typicode/json-server/actions/workflows/node.js.yml/badge.svg )] ( https://github.com/typicode/json-server/actions/workflows/node.js.yml )
4
4
5
- ## Usage
6
-
7
- Install ` json-server `
5
+ ## Install
8
6
9
7
``` shell
10
8
npm install json-server@alpha
11
9
```
12
10
13
- Create a ` db.json ` file or run ` json-server db.json ` to create one with some default resources
11
+ ## Usage
14
12
15
- > [ !TIP]
16
- > You can also use [ json5] ( https://json5.org/ ) format by creating a ` db.json5 ` instead
13
+ Create a ` db.json ` or ` db.json5 ` file
17
14
18
15
``` json
19
16
{
@@ -28,8 +25,15 @@ Create a `db.json` file or run `json-server db.json` to create one with some def
28
25
}
29
26
```
30
27
28
+ Pass it to JSON Server CLI
29
+
31
30
``` shell
32
31
json-server db.json
32
+ ```
33
+
34
+ Get a REST API
35
+
36
+ ``` shell
33
37
curl -H " Accept: application/json" -X GET http://localhost:3000/posts/1
34
38
{
35
39
" id" : " 1" ,
@@ -45,7 +49,8 @@ Run `json-server --help` for a list of options
45
49
GET /posts
46
50
GET /posts/:id
47
51
POST /posts
48
- PUT /posts
52
+ PUT /posts/:id
53
+ PATCH /posts/:id
49
54
DELETE /posts/:id
50
55
```
51
56
You can’t perform that action at this time.
0 commit comments