Mock API Server json server - Tuong-Nguyen/JavaScript-Structure GitHub Wiki
json-server https://github.com/typicode/json-server
-
Install
npm install -g json-server
-
Setup Create a db.json which contains sample data for Resources. json-server will create API for those resources
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
- Start server
json-server --watch db.json --port 4001
GET - POST - PUT - PATCH - DELETE APIs are created for resources (posts - comments - profile)
- Example: Course - Author API http://192.168.104.45:4001/