Files
FlutterUnit/lib/app/utils/http_utils/logs_interceptor.dart
2022-03-26 18:10:17 +08:00

29 lines
995 B
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:dio/dio.dart';
class LogsInterceptors extends InterceptorsWrapper {
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
// print("==========请求baseUrl${options.baseUrl} ==========");
// print("==========请求url${options.path} ==========");
// print('==========请求头: ' + options.headers.toString()+"==========");
// if (options.data != null) {
// print('==========请求参数: ' + options.data.toString()+"==========");
// }
return handler.next(options);
}
@override
void onError(DioError err, ErrorInterceptorHandler handler) {
print('==========请求异常: ' + err.toString()+"==========");
if(err.response!=null){
print('==========请求异常信息: ' + err.response.toString()+"==========");
}
return handler.next(err);
}
@override
void onResponse(Response response, ResponseInterceptorHandler handler) {
return handler.next(response); // continue
}
}