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)
- Access response data type <T> in Interceptor. HOT 5
- SOCKS5 PROXY SUPPORT HOT 1
- Dio on Windows : Invalid media type: expected no more input. HOT 3
- I cannot set a content-type of a form-data field HOT 5
- DioException (DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code. HOT 3
- The connection errored: Connection refused This indicates an error which most likely cannot be solved by the library. HOT 2
- [Web] ERROR_TYPE: DioExceptionType.connectionError HOT 2
- Flutter web deployment HOT 1
- [Dio native adapter] proxy HOT 2
- Exception has occurred. DioException (DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code. The status code of 401 has the following meaning: "Client error - the request contains bad syntax or cannot be fulfilled" Read more about status codes at https://developer.mozilla.org/en-US/docs/Web/HTTP/Status In order to resolve this exception you typically have either to verify and fix your request code or you have to fix the server code. ) HOT 1
- error 404 when trying to download a file. HOT 3
- How to mock Dio.interceptors.add when write unit test? HOT 1
- Conditionally allows relative path for `baseUrl` HOT 11
- Need a way to catch DioException [request cancelled] from the caller code HOT 3
- 有没有大佬帮我看看我的代码有什么问题,handler.resolve(res) 后,原始请求返回值一直为空,不知道为什么? HOT 1
- I don't know where the problem is with my code. After handler.reslove(res), the return value of the original request is always empty. HOT 3
- [Flutter Web] dio.get() sends options. HOT 1
- How to use handler.reject in onError of QueuedInterceptor HOT 1
- [native_dio_adapter] Exception fetching LoggerImpl class HOT 4
- http请求头不标准,大小写全部错误 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.