@@ -47,10 +47,12 @@ Dio getDio({options, loading}) {
47
47
print ("返回值 ${response .data }" );
48
48
print ('=========【请求成功】End============' );
49
49
await AppLoading .afterResponse (response.request.uri, loading);
50
- return response;
50
+ return response;
51
51
},
52
52
onError: (DioError e) async {
53
- await AppLoading .afterResponse (e.request.uri, loading);
53
+ print ('e.request.uri=======================${e .request }' );
54
+ if (e.request != null && e.request.uri != null )
55
+ await AppLoading .afterResponse (e.request.uri, loading);
54
56
dynamic msg = e.message;
55
57
dynamic code = 0 ; // 错误码
56
58
dynamic status = e.type; // http请求状态
@@ -60,21 +62,20 @@ Dio getDio({options, loading}) {
60
62
status = e.response.statusCode;
61
63
}
62
64
print ('========【请求失败 Start】=============' );
63
- print ("请求地址 ${e .request . uri }" );
65
+ print ("请求地址 ${e .request }" );
64
66
print ("状态码 ${status }" );
65
67
print ("返回msg ${msg }" );
66
68
print ('=========【请求失败 End】============' );
67
69
return dio.reject ({'msg' : msg, 'code' : code, 'status' : status});
68
70
},
69
71
));
70
72
dio.interceptors.add (LogInterceptor (responseBody: false )); //开启请求日志
71
-
73
+
72
74
return dio;
73
75
}
74
76
75
77
Future <dynamic > get ({url, data = const {}, options, loading}) async {
76
- return getDio (options: options, loading: loading ?? Map ())
77
- .get (url);
78
+ return getDio (options: options, loading: loading ?? Map ()).get (url);
78
79
}
79
80
80
81
Future post ({url, data = const {}, options, loading}) async {
0 commit comments