# `GET` /api/tweets/:id ## API 功能 取得一筆推文資料。 * 必須登入。 * 取得推文的 likeCount、replyCount。 * 確認使用者是否 like 了這篇推文。 ## 前端傳入資料 ### parameters |name|description| |---|---| |`id`| 推文的 `id` | ### req.body None. ## 後端回傳資料 ### 驗證成功 ```json // status code: 200 { "id": 4, "description": "content text", "createdAt": "2022-07-21T14:16:39.000Z", "User": { "id": 2, "name": "user1", "account": "user1", "avatar": "<url>" }, "replyCount": 3, "likeCount": 5, "isLiked": true } ``` ### 傳入資料格式有誤 發生原因: 沒有提供 tweet `id` 。 ```json // status code: 400 { "status": "error", "message": "id of tweet is required" } ``` ### 查詢失敗 發生原因: 沒有找到推文。 ```javascript // status code: 400 { "status": "error", "message": "tweet not found" } ``` ## 相關連結 * [回首頁](https://hackmd.io/@twitter-2022/index) * [API 總表](/Gl56cI2LQ5ObBpmQnbnphw) ###### tags: `API-doc`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up