getCurrencyListings method
Implementation
Future getCurrencyListings() async {
try {
dynamic response;
response = await http.get(
Uri.parse('${Util.END_POINT}/currencies'),
headers: <String, String>{
'Content-Type': 'application/json; charset=UTF-8',
},
);
//Handling Status codes Error Via Snackbar
if (response.statusCode == 201 || response.statusCode == 200) {
return jsonDecode(response.body);
} else if (response.statusCode == 401) {
//Bad Public key
debugPrint("Your public key is not authorized");
return jsonDecode(response.body);
} else if (response.statusCode == 404) {
debugPrint("getCurrencyListings() service status: 404");
return jsonDecode(response.body);
} else if (response.body == "null") {
debugPrint("getCurrencyListings() returning null from API");
return jsonDecode(response.body);
} else {
return jsonDecode(response.body);
}
} catch (e) {
rethrow;
}
}