get static method
Implementation
static Future get(
String path, {
Map<String, dynamic> qparams = const {},
Uri? useUri,
String? serviceID,
}) async {
var client = http.Client();
late Uri url;
try {
url = useUri ?? uri(path, queryparams: qparams, serviceID: serviceID);
final response = await client.get(url, headers: _myHeaders());
final decoded = json.decode(response.body);
if ((response.statusCode / 100).truncate() != 2) {
throw ApiErrorResponse(decoded["message"]);
}
return decoded["data"];
} catch (e) {
if (e is SocketException) throw ConnectionRefuted(err: e.message, url: url);
if (e is HttpException) {
throw ApiErrorResponse("Couldn't find the post 😱");
}
if (e is FormatException) throw RespuestaInvalida();
rethrow;
} finally {
client.close();
}
}