getAPI method
Implementation
Future<BaseResponse> getAPI(String path, data, {bool hasHeader = true, bool hasDomain = true, int timeout = 20}) async {
final baseResponse = BaseResponse();
try {
http.Response response;
final prefs = await SharedPreferences.getInstance();
final header = await _getHeader(hasAuthen: hasHeader && prefs.containsKey(keyIsLogin) && prefs.getBool(keyIsLogin)!);
response = await httpClient.get(Uri.parse((hasDomain ? baseUrl : '') + path), headers: header).timeout(Duration(seconds: timeout));
baseResponse.fromJson(jsonDecode(response.body), data);
} catch (e) {
return _responseError(baseResponse, e);
}
return baseResponse;
}