[Swift-d26] - 實戰開發 - TODOList - API 前置資料準備
接下來是要串 隔壁棚的 API XD
從前幾天的 APP 組成
我們所需要的資料大概會是以下幾種:
- GET todo list
GET http://192.168.1.158:3000/user/kerkerj/todos
return:
[
{
"_id": "54441f64d84f1ea412db855c",
"updated_at": "2014-10-19T20:30:28.797Z",
"created_at": "2014-10-19T20:30:28.797Z",
"content": "task11syy",
"user_id": "kerkerj",
"__v": 0
},
{
"_id": "54441f6fd84f1ea412db855e",
"updated_at": "2014-10-19T20:30:39.957Z",
"created_at": "2014-10-19T20:30:39.957Z",
"content": "task13",
"user_id": "kerkerj",
"__v": 0
}
]
- Get a todo task
GET http://192.168.1.158:3000/user/kerkerj/todos/54441f64d84f1ea412db855c
return:
{
"_id": "54441f64d84f1ea412db855c",
"updated_at": "2014-10-19T20:30:28.797Z",
"created_at": "2014-10-19T20:30:28.797Z",
"content": "task11syy",
"user_id": "kerkerj",
"__v": 0
}
- Add a todo task
POST http://192.168.1.158:3000/user/kerkerj/todos/
data: {"content": "your data"}
return: the data you sent
- Update a todo task
PUT http://192.168.1.158:3000/user/kerkerj/todos/
data: {"content": "your data"}
return: the data you sent
- Delete a todo task
DELETE http://192.168.1.158:3000/user/kerkerj/todos/54441f64d84f1ea412db855c
return
{"success": "true"}
從以上資料可以知道
最重要的欄位就是 _id, user_id, content
user_id 我們在 app 中就直接寫死了
所以最重要的就是 content 及 _id
今天先允許我偷懶一下,明天就要開始寫 api utility 給 swift 用