mirror of
https://github.com/typicode/json-server.git
synced 2025-08-02 11:32:47 +08:00
Update README.md
This commit is contained in:
19
README.md
19
README.md
@ -20,8 +20,7 @@ See also:
|
||||
<!-- toc -->
|
||||
|
||||
- [Sponsorship](#sponsorship)
|
||||
- [Example](#example)
|
||||
- [Install](#install)
|
||||
- [Getting started](#getting-started)
|
||||
- [Routes](#routes)
|
||||
* [Plural routes](#plural-routes)
|
||||
* [Singular routes](#singular-routes)
|
||||
@ -63,7 +62,13 @@ See also:
|
||||
|
||||
</details>
|
||||
|
||||
## Example
|
||||
## Getting started
|
||||
|
||||
Install JSON Server
|
||||
|
||||
```
|
||||
npm install -g json-server
|
||||
```
|
||||
|
||||
Create a `db.json` file
|
||||
|
||||
@ -82,7 +87,7 @@ Create a `db.json` file
|
||||
Start JSON Server
|
||||
|
||||
```bash
|
||||
$ json-server --watch db.json
|
||||
json-server --watch db.json
|
||||
```
|
||||
|
||||
Now if you go to [http://localhost:3000/posts/1](http://localhost:3000/posts/1), you'll get
|
||||
@ -98,12 +103,6 @@ Also when doing requests, it's good to know that:
|
||||
- Id values are not mutable. Any `id` value in the body of your PUT or PATCH request will be ignored. Only a value set in a POST request will be respected, but only if not already taken.
|
||||
- A POST, PUT or PATCH request should include a `Content-Type: application/json` header to use the JSON in the request body. Otherwise it will result in a 200 OK but without changes being made to the data.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ npm install -g json-server
|
||||
```
|
||||
|
||||
## Routes
|
||||
|
||||
Based on the previous `db.json` file, here are all the default routes. You can also add [other routes](#add-custom-routes) using `--routes`.
|
||||
|
Reference in New Issue
Block a user