我在尝试向API发出GET请求
发生异常:DioError [DioErrorType.DEFAULT]:HttpException:即使contentLength被指定为大于0:134,也没有内容。
uri = https://app.meatified.com/api/v1/transactions/verify/1e7807a0-80b4-4951-b6f0-72b329010bda stackTrace: #0
GET请求没有提示我的端点,有关更多信息,请参见下面的日志
下面是我的拦截器课程
class MeatityHttpInterceptor implements Interceptor {
Map<String, dynamic> _header;
FireBaseAuthProvider _auth;
MeatityHttpInterceptor() {
_auth = new FireBaseAuthProvider();
_header = {
HttpHeaders.contentTypeHeader: "application/json"
};
}
@override
onError(DioError err) {
// TODO: implement onError
return null;
}
@override
onRequest(RequestOptions options) async {
//Hope this will work.
FirebaseUser loggedInUser = await _auth.currentUser();
if(loggedInUser != null){
String token = await loggedInUser.getIdToken(refresh: true);
_header.addAll({HttpHeaders.authorizationHeader: token});
}
options.connectTimeout = 10000;
options.responseType = ResponseType.json;
options.baseUrl = "https://app.meatified.com/api/v1";
options.contentType = ContentType.parse("application/json");
options.receiveTimeout = 10000;
options.headers = _header;
print('send request:path:${options.path},baseURL:${options.baseUrl}');
return options;
}
@override
onResponse(Response response) {
print('HTTP INTERCEPTOR RESPONSE');
print(response.data);
// print(response.realUri);
return null;
}
}