JSON Severは、簡単にREST APIのサーバーを作れるツールです。
REST APIのデータをJSONファイルで用意するだけで作れます。
JSON Serverをインストールする
以下のコマンドを実行してください。
npm install json-server
JSONファイルを用意する
JSON Severを起動するフォルダに、「db.json」を作ります。
{
"users": [
{"id": 1, "name": "taro"},
{"id": 2, "name": "jiro"}
]
}
JSON Serverを起動する
以下のコマンドを実行してください。
npx json-server --watch db.json --port 3001
以上です。