getWithQueryParams method
Implementation
Future<dynamic> getWithQueryParams(
Uri uri, Map<String, String> headers) async {
return http
.get(uri, headers: headers)
.then((http.Response response) {
final String res = response.body;
final int statusCode = response.statusCode;
if (statusCode < 200 || statusCode >= 400) {
throw Exception(_decoder.convert(res)['error']['message']);
}
return res;
})
.catchError((onError) {
if (onError.toString().toLowerCase().contains("socket")) {
throw Exception("Server timeout");
} else {
throw Exception(onError.toString().replaceAll("Exception:", ""));
}
})
.timeout(const Duration(seconds: 10))
.catchError((onError) {
if (onError.toString().toLowerCase().contains("timeout")) {
throw Exception("Server timeout");
} else {
throw Exception(onError.toString().replaceAll("Exception:", ""));
}
});
}