Comments (4)
Supported! please update dio to latest version firstly.
you can custom the ValidateStatus
of options:
/// `validateStatus` defines whether the request is successful for a given
/// HTTP response status code. If `validateStatus` returns `true` ,
/// the request will be perceived as successful; otherwise, considered as failed.
ValidateStatus validateStatus;
Examples
dio.options.validateStatus=(int status){
return status >= 200 && status < 300 || status == 304;
}
from dio.
var dio=Dio();
dio.options.validateStatus=(int status){
return status >0;
}
dio.post()
restful api返回错误码为1000,validateStatus无效,依然发生异常
from dio.
@guodf 这个status是http状态码,并不是API中定义的错误码
from dio.
Supported! please update dio to latest version firstly. you can custom the
ValidateStatus
of options:/// `validateStatus` defines whether the request is successful for a given /// HTTP response status code. If `validateStatus` returns `true` , /// the request will be perceived as successful; otherwise, considered as failed. ValidateStatus validateStatus;Examples
dio.options.validateStatus=(int status){ return status >= 200 && status < 300 || status == 304; }
设置了validateStatus后dart代码确实不需要捕获异常了,但是客户端浏览器的console里还是能看到红色的error提示403,请教下有办法隐藏浏览器的提示嘛?
from dio.
Related Issues (20)
- Error Dio flutter web HOT 1
- upload file send timeout
- Header is out of order HOT 3
- `ResponseType.stream` is not working on web. HOT 1
- [🔔 Dio] sendTimeout cannot be used without a request body to send HOT 2
- `Transformer.isJsonMimeType` throws format exceptions without caught
- onError is not returning any error HOT 3
- Error when uploading image using MultipartFile.fromBytes in version 5.4.3+1 HOT 1
- 为什么dio的fromMap会将MultipartFile自动放入files字段中 HOT 1
- Error: The method 'debugLog' isn't defined for the class 'BrowserHttpClientAdapter'. HOT 1
- Version 5.5.0 brakes the web build HOT 1
- Is it now possible to use DIO / dio_web_adapter with Web/WASM? HOT 41
- Dio 5.5 broke compilation for WASM HOT 6
- ResponseType.stream returns responce all at once on Web HOT 1
- Date header not parsed correctly HOT 1
- set proxy for BrowserHttpClientAdapter HOT 1
- Dio fetch can't catch error HOT 1
- Return the app to the desktop, then switch to Wi Fi in the system. After switching to Wi Fi, click on the desktop app icon to enter the app. At this point, there is an exception when sending network requests. This is highly likely to occur on Ios HOT 5
- when using "handler.reject(error);" in onError of interceptors, I cannot DioException in .catchError(), but find it in .then(). HOT 1
- Dio cannot connect to the Internet after VPN is enabled on iOS devices HOT 1
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 dio.