Skip to content

Instantly share code, notes, and snippets.

@LarryLuTW
Last active August 13, 2016 10:49
Show Gist options
  • Save LarryLuTW/ea48aed8a551f26f67a07f39100d335e to your computer and use it in GitHub Desktop.
Save LarryLuTW/ea48aed8a551f26f67a07f39100d335e to your computer and use it in GitHub Desktop.

Database 格式

| id | name  | birthday |
|----|-------|----------|
| 0  | Larry | 19960806 |
| 1  | Kyrie | 19960326 |
| 2  | John  | 20001010 |

提供以下 API


得到所有成員的 id 及名字

GET /api/member

譬如說 GET /api/member 就會得到以下結果

[
  {"id": 0, “name”: "Larry"},
  {"id": 1, "name": "Kyrie"},
  {"id": 2, "name": "John"}
]

得到特定 id 的個人資料

GET /api/member/:id

譬如說 GET /api/member/0 就會得到以下結果

{"id": 0, "name": "Larry", "birthday": "19960806"}

新增一位成員

POST /api/member
body: {
    name: "OOO",
    birthday: "YYYYMMDD"
}

譬如說 POST /api/member

body: {
    name: 'Mary',
    birthday: '20060101'
}

就會得到新的 DB

| id | name  | birthday |
|----|-------|----------|
| 0  | Larry | 19960806 |
| 1  | Kyrie | 19960326 |
| 2  | John  | 20001010 |
| 3  | Mary  | 20060101 |

刪除特定 id

DELETE /api/member/:id

譬如說 DELETE /api/member/0 就會得到新的 DB

| id | name  | birthday |
|----|-------|----------|
| 1  | Kyrie | 19960326 |
| 2  | John  | 20001010 |
| 3  | Mary  | 20060101 |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment