@@ -47,10 +47,12 @@ Dio getDio({options, loading}) {
4747 print ("返回值 ${response .data }" );
4848 print ('=========【请求成功】End============' );
4949 await AppLoading .afterResponse (response.request.uri, loading);
50- return response;
50+ return response;
5151 },
5252 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);
5456 dynamic msg = e.message;
5557 dynamic code = 0 ; // 错误码
5658 dynamic status = e.type; // http请求状态
@@ -60,21 +62,20 @@ Dio getDio({options, loading}) {
6062 status = e.response.statusCode;
6163 }
6264 print ('========【请求失败 Start】=============' );
63- print ("请求地址 ${e .request . uri }" );
65+ print ("请求地址 ${e .request }" );
6466 print ("状态码 ${status }" );
6567 print ("返回msg ${msg }" );
6668 print ('=========【请求失败 End】============' );
6769 return dio.reject ({'msg' : msg, 'code' : code, 'status' : status});
6870 },
6971 ));
7072 dio.interceptors.add (LogInterceptor (responseBody: false )); //开启请求日志
71-
73+
7274 return dio;
7375}
7476
7577Future <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);
7879}
7980
8081Future post ({url, data = const {}, options, loading}) async {
0 commit comments