Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-2xx response code? #13

Closed
everpcpc opened this issue Mar 6, 2018 · 4 comments
Closed

Non-2xx response code? #13

everpcpc opened this issue Mar 6, 2018 · 4 comments

Comments

@everpcpc
Copy link

everpcpc commented Mar 6, 2018

It's confused returning a HTTP 200 OK but an error in the response body.

@Sai
Copy link
Member

Sai commented Mar 6, 2018

API 一般都这样实现,HTTP Status Code 只表示服务器状态

@ghost
Copy link

ghost commented Mar 7, 2018

RESTful API 服務會使用 HTTP Status Code 來表示狀態,
但並不必須是這樣,像是最近有點火的這篇文章

但作為一個公開 API 服務,用戶假定他會是一個 RESTful 的 API。

@trim21
Copy link
Contributor

trim21 commented Jun 23, 2018

@Sai 这样有一个问题, 比如 https://api.bgm.tv/subject/{subject_id}/ep 这个api,无论对应的subject是否存在,http status code都是200. 当subject不存在的时候的时候存在一个response.code,但是在成功返回的时候并没有一个code字段, 而是直接返回了数据.
但是又有一些api 比如https://api.bgm.tv/subject/{subject_id}/watched_eps这个api,无论成功与否,都有一个response.code,而且这个code表示了api请求的成功与否.
希望能把两种情况统一一下,比如api无论如何都会返回一个response.code, 请求成功的时候不是直接返回对应的数据,而是把数据放在response.data中, 或者是使用HTTP status code表示请求的状态,在前端js就就可以根据请求成功与否做统一的错误处理了。

还有一个问题 请求一个不正确的URL 比如api.bgm.tv/subj http status code还是200…

@Sai
Copy link
Member

Sai commented Jun 25, 2018

我研究一下

@trim21 trim21 closed this as completed May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants