๐ json-server๋ json ํ์ผ์ ์ฌ์ฉํ์ฌ ๊ฐ๋จํ ์๋ฎฌ๋ ์ด์ ์ ์ํ REST API Mock server๋ฅผ ๊ตฌ์ถํ ์ ์๋ ํด์ด๋ค.
๐ฉ ์ค์น
npm install -g json-server
๐ฉ db.json ํ์ผ ๋ง๋ค๊ธฐ
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
๐ฉ ์คํ
json-server --watch db.json
๋๋
**$ json-server --watch db.json --port 5000**
โ ์ํ๋ port ๋๋ฒ๋ฅผ ์ ๋ ฅํด์ฃผ๋ฉด ํด๋น ๋๋ฒ๋ก ์คํ
์ ๋ ฅํ์ง ์์ผ๋ฉด 3000 port๋ก ๋ฐ๋ก ์คํ๋๋ค.