# `GET` /api/users/:id/followers
<!-- 一級標題自動成為筆記名稱 -->
## API 功能
取得某位使用者的追蹤者。
* 需註冊才可進入
* 回傳某位使用者的追蹤者。
* 資料依照追蹤成立時間排序(由新到舊)。
* 每筆資料中包含
* follower的資料(followerId, createdAt)
* followerId的user資料(name, account, avator, introduction)
* 目前使用者是否追蹤(isFollowing)
* followId = followerId(與`GET /api/users/:id/followings`相同名稱使前端可套用相同模板)
## 前端傳入資料
### query string
分頁功能 (optional)
| name | description | default |
| ------- | -------------------------| ------- |
| `count` | 一次取的資料筆數/每頁資料筆數 | null |
| `page` | 頁數 | null |
### parameters
params | Description
--- | ---
`id` | 欲查詢追蹤者的user id
### req.body
None
## 後端回傳資料
### 成功
```json
// status code: 200
[
{
"followerId": 2,
"createdAt": "2022-08-03T11:10:34.000Z",
"name": "user111",
"account": "user1",
"avatar": "https://avatar-rul",
"introduction": "helloworld",
"isFollowing": false,
"followId": 2
},
{
"followerId": 3,
"createdAt": "2022-08-03T11:10:34.000Z",
"name": "blanditiis a",
"account": "user2",
"avatar": "https://avatar-rul",
"introduction": "helloworld",
"isFollowing": true,
"followId": 3
},
// ...more followers
]
```
### 失敗
發生原因:使用者 token 驗證不通過。
```javascript
// status code: 401
{
"status": "error",
"message": "Unauthorized. Please login first."
}
```
發生原因:找不到與傳入 `id` 對應的 user。
```javascript
// status code: 404
{
"status": "error",
"message": "User is not found"
}
```
## 相關連結
* [回首頁](https://hackmd.io/@twitter-2022/index)
* [API 總表](/Gl56cI2LQ5ObBpmQnbnphw)
###### tags: `API-doc`