Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 Fix interceptor codes in READMEs #1745

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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