Hướng dẫn cài json sever json-sever(ok)

https://github.com/typicode/json-server

First, you need to check json-server installed globally or not. or you can install it globally by

npm install -g json-server

If you install it locally in your project, use npx to run it

npx json-server --watch db.json

https://stackoverflow.com/questions/55547572/json-server-is-not-recognized-as-an-internal-or-external-command

npm install -g json-server
Create a db.json file with some data
{
  "posts": [
    { "id": 1, "title": "json-server", "author": "typicode" }
  ],
  "comments": [
    { "id": 1, "body": "some comment", "postId": 1 }
  ],
  "profile": { "name": "typicode" }

json-server --watch db.json
Now if you go to http://localhost:3000/posts/1, you'll get
{ "id": 1, "title": "json-server", "author": "typicode" }

Đọc thêm cách dùng lệnh

https://app.gitbook.com/@learnreac/s/project/cach-xay-dung-json-server-json-server-bang-cau-truc-lenh-nodejs-ok

Last updated

Was this helpful?