get method
发起get请求
params 发起请求的param参数
cancelToken
取消请求的cancelToken
Implementation
Future<void> get({
required CancelToken cancelToken,
}) async {
Options requestOptions = Options();
Map<String, dynamic>? _authorization = getAuthorizationHeader();
if (_authorization != null) {
requestOptions = requestOptions.copyWith(headers: _authorization);
}
Response? response;
var url = path;
assert(url.isNotEmpty, 'url不能为空');
try {
response = await dio.get(
url,
queryParameters: params,
options: requestOptions,
cancelToken: cancelToken,
);
success(response.data);
} on DioError catch (e) {
// error统一处理
AppException appException = AppException.create(e, 1);
// 错误提示
debugPrint('DioError===: ${appException.toString()}');
error(appException.getMessage());
}
}