Update README.md

This commit is contained in:
typicode
2018-07-14 06:47:34 +02:00
committed by GitHub
parent e6fdcc35eb
commit 350cd67eaf

View File

@ -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`.