Some API uses query string style, Can we use JSON Server to support query string style API ?
Version
JSON Server 0.17.1
Add Route
routes.json
{
"/api/posts": "/posts",
"/api/posts?id=:id": "/posts/:id"
}
JSON Server only supports URI style API, we have to define query string style API mapping on routes.json
Apply New Route
$ json-server db.json --routes routes.json
- Start JSON Server by
db.json
database file androutes.json
route file
Conclusion
- By simple route file, we can simulate query string style API by JSON Server