# `GET` api/users/:id <!-- 一級標題自動成為筆記名稱 --> ## API 功能 取得一筆user資料 * User資料(不含passwword, 成立時間,更新時間) * 該user的關聯資料數量 * 推文數量(tweetCount) * 跟隨的數量(followingCount) * 跟隨者的數量(followerCount) ## 前端傳入資料 ### parameters | params | Description | required | | ------ | ----------- | -------- | | `id` | user's id | true | ### req.body None ## 後端回傳資料 ### 成功 ```json // status code: 200 { "id": 2, "name": "user1", "account": "user1", "email": "user1@example.com", "avatar": "https://avatar-url", "cover": "https://cover-url", "introduction": "balabala", "role": "user", "tweetCount": 10, "followingCount": 4, "followerCount": 2 } ``` ### 失敗 發生原因:資料庫查詢正常,但傳入的id查無此人。 ```json // status code: 404 { "status": "error", "message": "User is not found." } ``` ## 相關連結 * [回首頁](https://hackmd.io/@twitter-2022/index) * [API 總表](/Gl56cI2LQ5ObBpmQnbnphw) ###### tags: `API-doc`