Chỉnh sửa url mặc định của json-server ví dụ thêm /api vào đường dẫn (ok)

C:\xampp\htdocs\api\db.json

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

C:\xampp\htdocs\api\package.json

{
  "name": "api",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "node main.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "json-server": "^0.17.0"
  },
  "devDependencies": {
    "nodemon": "^2.0.15"
  }
}

Last updated