Comments (4)
RESTful API 服務會使用 HTTP Status Code 來表示狀態,
但並不必須是這樣,像是最近有點火的這篇文章,
但作為一個公開 API 服務,用戶假定他會是一個 RESTful 的 API。
from api.
API 一般都这样实现,HTTP Status Code 只表示服务器状态
from api.
@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…
from api.
我研究一下
from api.
Related Issues (20)
- API doc 链接指向错误
- 希望获取用户收藏的API,能够返回用户收藏条目的时间 HOT 1
- 调用 更新进度api 显示TypeError: NetworkError when attempting to fetch resource. HOT 3
- 调用api 批量更新收视进度 会清空已有进度 HOT 3
- 部分接口为啥没有挂在 /v0 路径下 HOT 3
- Patch /v0/users/-/collections/{subject_id}/episodes把p1从未看更新至已看时报错500 HOT 1
- PATCH /v0/users/-/collections/{subject_id} 无法修改 private 属性 HOT 14
- 504 GateWay time-out,无法正常获得数据,请求修复 HOT 1
- 能否考虑取消只有使用username才能查询用户信息
- 字段命名不统一 HOT 3
- 官方API返回大量错误信息 HOT 20
- fetch 请求 PATCH 方法跨域问题 HOT 2
- /calendar中item的summary值始终为空
- Feature Request: Character Search 人物检索 API HOT 3
- 有没有关于小组功能的api HOT 3
- 修改收藏番剧完成度 HOT 4
- 问题:Legacy API是不是用任何方法都无法读取里番了? HOT 1
- 请问是否能加入magi问答相关api HOT 1
- /v0/indices/{index_id}/subjects获取不到条目数据 HOT 2
- 条目API 404 Not Found 问题 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api.