安裝

shell> npm install -g json-server

db.json

{
  "posts": [{
    "id": 1,
    "title": "json-server",
    "author": "typicode"
  }],
  "comments": [{
    "id": 1,
    "body": "some comment",
    "postId": 1
  }],
  "profile": {
    "name": "typicode"
  }
}

Start JSON Server

shell> json-server --watch db.json
shell> json-server --watch db.json --port 3004

shell> json-server http://example.com/file.json
shell> json-server http://jsonplaceholder.typicode.com/db

http://localhost:3000/posts/1

{ "id": 1, "title": "json-server", "author": "typicode" }

:books: 參考網站:

powered by Gitbook最後更新: 2017-11-30 14:13:49

results matching ""

    No results matching ""