getData static method
Implementation
static Future<dynamic> getData({
required String url,
Map<String, String> header = const {},
}) async {
try {
Response response = await get(Uri.parse(url), headers: header);
log('GET status: ${response.statusCode}');
if (response.statusCode == 200) {
if (response.body.isNotEmpty) {
return jsonDecode(response.body);
}
return null;
}
throw ApiFailedException(msg: 'failed to get the data :(');
} on ApiFailedException catch (e) {
log(e.toString());
return null;
}
}