Quick start develop FE without Backend resolved.
-
Run a mock server as a development APIs server.
-
Easy declare routes and fake response payload.
-
Follow standard RESTful APIs rules.
-
Reduce stuck integrate FE - BE teams.
-
Using
json-server&json-server-auth. So see these official documents before!
Ex: need add new API /api/products to fetch products data.
-
Goals:
- GET: /api/products?page=&size= - GET: /api/products/:id - POST: /api/products - PUT: /api/products/:id - DELETE: /api/products/:id
-
Steps:
-
Add your key
productsroute to endmock/db.json. Ex:````json { ... "products": [ { "id": 1, "name": "keyboard", "brand": "leopold" }, { "id": 2, "name": "mouse", "brand": "leopold" } ] } ```
-
- Modified
userskey inmock/db.json
- Modified
mock/routes.json, follow standard rewrite regex from express router.