Code Monkey home page Code Monkey logo

Comments (3)

wendux avatar wendux commented on May 11, 2024

A request must correspond to a response, even if it failed.
you can handle successful response by only suppling callback to then instead of using async...await to ignore exception:

dio.get(...).then((r)=>print(r))

from dio.

jlcool avatar jlcool commented on May 11, 2024

@wendux 请求需要做单独的异常处理还必须得用await,不能用then。使用then,有异常catch不到,能不能不抛出异常而是返回一个异常状态,直接用then获取处理,比如这样
.then((response,error){ if(error!=null){ } })

from dio.

jlcool avatar jlcool commented on May 11, 2024

@wendux 请求需要做单独的异常处理还必须得用await,不能用then。使用then,有异常catch不到,能不能不抛出异常而是返回一个异常状态,直接用then获取处理,比如这样
.then((response,error){ if(error!=null){ } })

onError 返回Response 就可以

from dio.

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.