get method
Make 'get' http call.
Implementation
Future<dynamic> get(String? path,
{Map? queryParameters, Map<String, String>? header}) async {
var finalUrl = api!.endpointUrl(path);
var responseJson;
if (queryParameters != null) {
queryParameters.forEach((k, v) {
finalUrl += !finalUrl.contains('?') ? '?$k=$v' : '&$k=$v';
});
}
try {
final response = await retry(
() => http.get(Uri.parse(finalUrl), headers: header ?? {}),
retryIf: (e) => e is SocketException || e is TimeoutException);
responseJson = _response(response);
} on SocketException {
throw FetchDataException('No Internet connection');
} on TimeoutException {
throw FetchDataException('Connection Timeout');
} catch (e) {
throw FetchDataException('Unhandled Exception : ${e.toString()}');
}
return responseJson;
}