getHttpForDevice<T> static method
void
getHttpForDevice<T>(})
Implementation
static void getHttpForDevice<T>(
String url, {
required Map<String, dynamic> parameters,
Function(Map response)? onSuccess,
Function(String error)? onError,
}) async {
Map<String, dynamic> param = {
'Accept': '*/*',
'Content-Type': 'application/json; charset=utf-8',
};
//更新header参数配置
UnitsForNetwork.dio?.options.headers = param;
try {
Response response;
Dio? dio = UnitsForNetwork.dio;
response = await dio!.get(url, queryParameters: parameters);
var responseData = response.data;
debugPrint(responseData.toString());
if (responseData != null) {
if (onSuccess != null) onSuccess(responseData);
} else {
if (onError != null) onError('?');
}
} catch (e) {
debugPrint('请求出错:$e');
if (onError != null) onError(e.toString());
}
}