
json 파일을 사용하여 간단한 시뮬레이션을 위한 REST API Mock server를 구축할 수 있는 툴
npm i json-server
yarn add json-server
포트 설정 --port 숫자
npx json-server --watch db.json --port 4000
yarn json-server --watch db.json --port 4000
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
http://localhost:4000/posts
http://localhost:4000/comments
http://localhost:4000/profile
Get 데이터 불러오기Post 데이터 업로드Put 데이터 수정 (지정한 데이터를 전부 수정)Patch 데이터 수정 (지정한 데이터 일부 수정)Delete 데이터 삭제GET /postsGET /posts/1POST /postsPUT /posts/1PATCH /posts/1DELETE /posts/1GET /profilePOST /profilePUT /profilePATCH /profile_page 페이지 수
_limit 불러올 데이터 양
GET /posts?_page=1
GET /posts?_page=1&_limit=20