Skip to content

Commit

Permalink
📝 Fix interceptor codes in READMEs (#1745)
Browse files Browse the repository at this point in the history
Fixes #1744.

### New Pull Request Checklist

- [x] I have read the
[Documentation](https://pub.dev/documentation/dio/latest/)
- [x] I have searched for a similar pull request in the
[project](https://github.com/cfug/dio/pulls) and found none
- [x] I have updated this branch with the latest `main` branch to avoid
conflicts (via merge from master or rebase)
- [ ] I have added the required tests to prove the fix/feature I'm
adding
- [x] I have updated the documentation (if necessary)
- [x] I have run the tests without failures
- [ ] I have updated the `CHANGELOG.md` in the corresponding package
  • Loading branch information
AlexV525 committed Mar 17, 2023
1 parent cdab4cc commit 9c30e9a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions dio/README-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,14 @@ dio.interceptors.add(
InterceptorsWrapper(
onRequest: (RequestOptions options, RequestInterceptorHandler handler) {
// 如果你想完成请求并返回一些自定义数据,你可以使用 `handler.resolve(response)`。
// 如果你想终止请求并触发一个错误,你可以使用 `handler.reject(error)`。
// 如果你想终止请求并触发一个错误你可以使用 `handler.reject(error)`。
return handler.next(options);
},
onResponse: (Response response, RequestInterceptorHandler handler) {
// 如果你想终止请求并触发一个错误,你可以使用 `handler.reject(error)`。
onResponse: (Response response, ResponseInterceptorHandler handler) {
// 如果你想终止请求并触发一个错误你可以使用 `handler.reject(error)`。
return handler.next(response);
},
onError: (DioError e, RequestInterceptorHandler handler) {
onError: (DioError e, ErrorInterceptorHandler handler) {
// 如果你想完成请求并返回一些自定义数据,你可以使用 `handler.resolve(response)`。
return handler.next(e);
},
Expand Down
14 changes: 7 additions & 7 deletions dio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -423,17 +423,17 @@ dio.interceptors.add(
// you can reject with a `DioError` using `handler.reject(dioError)`.
return handler.next(options);
},
onResponse: (Response response, RequestInterceptorHandler handler) {
onResponse: (Response response, ResponseInterceptorHandler handler) {
// Do something with response data.
// If you want to reject the request with a error message,
// you can reject a `DioError` object eg: `handler.reject(dioError)`.
// you can reject a `DioError` object using `handler.reject(dioError)`.
return handler.next(response);
},
onError: (DioError e, RequestInterceptorHandler handler) {
// Do something with response error
// If you want to resolve the request with some custom data
// you can resolve a `Response` object eg: `handler.resolve(response)`.
return handler.next(e);//continue
onError: (DioError e, ErrorInterceptorHandler handler) {
// Do something with response error.
// If you want to resolve the request with some custom data,
// you can resolve a `Response` object using `handler.resolve(response)`.
return handler.next(e);
},
),
);
Expand Down

0 comments on commit 9c30e9a

Please sign in to comment.