Coder Social home page Coder Social logo

关于报错信息 about fly HOT 1 CLOSED

hainuo avatar hainuo commented on June 15, 2024
关于报错信息

from fly.

Comments (1)

wendux avatar wendux commented on June 15, 2024
  1. 请先查看文档中“错误处理”部分内容,0代表超时
  2. 若是服务器发生错误时,err对象会有一个message属性,对应的是xhr.statusText. 如当 status 为404时,大多数服务器会将statusText 设为“Not Found”, 但这并非标准,有些服务器并不会设置statusText,这时err.message就为空
  3. 不建议API在http返回错误码的时候(如404、500)时再返回内容
  4. 如果非要在http 返回错误码时获取body的内容。你可以使用如下代码:
     var request=fly.get("xxx")
     request.then(d=>{}).catch(e=>{
       //打印出body内容
       console.log(request.engine.responseText)
     })

注意:fly在发起请求后返回的promise对象中会扩展一个 engine 属性,代表当前的xmlHttpRequest对象,但此属性不具有传递性,所以你不能在调用了 catch then 之后再获取 engine.

from fly.

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.