onResponse method

  1. @override
void onResponse(
  1. Response response,
  2. ResponseInterceptorHandler handler
)

The callback will be executed on success. If you want to continue the response, call handler.next.

If you want to complete the response with some custom data directly, you can resolve a Response object with handler.resolve and other response interceptor(s) will not be executed.

If you want to complete the response with an error message, you can reject a DioError object with handler.reject.

Implementation

@override
void onResponse(Response response, ResponseInterceptorHandler handler) {
  _saveCookies(response).then((_) => handler.next(response)).catchError((e, stackTrace) {
    var err = DioError(requestOptions: response.requestOptions, error: e);
    err.stackTrace = stackTrace;
    handler.reject(err, true);
  });
}