Coder Social home page Coder Social logo

Non-2xx response code? about api HOT 4 CLOSED

bangumi avatar bangumi commented on August 27, 2024
Non-2xx response code?

from api.

Comments (4)

 avatar commented on August 27, 2024 2

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

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

from api.

Sai avatar Sai commented on August 27, 2024

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

from api.

trim21 avatar trim21 commented on August 27, 2024

@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.

Sai avatar Sai commented on August 27, 2024

我研究一下

from api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.