Files
FlutterUnit/lib/app/utils/http_utils/logs_interceptor.dart
2021-01-25 08:25:57 +08:00

30 lines
912 B
Dart
Raw 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
onRequest(RequestOptions options) async{
// print("==========请求baseUrl${options.baseUrl} ==========");
// print("==========请求url${options.path} ==========");
// print('==========请求头: ' + options.headers.toString()+"==========");
// if (options.data != null) {
// print('==========请求参数: ' + options.data.toString()+"==========");
// }
return options;
}
@override
onResponse(Response response)async {
if (response != null) {
// var responseStr = response.toString();
}
return response; // continue
}
@override
onError(DioError err) async{
print('==========请求异常: ' + err.toString()+"==========");
print('==========请求异常信息: ' + err.response?.toString()+"==========" ?? "==========");
return err;
}
}