I want check if Api Url Statuscode is 200 , everything is ok untill in else statement .
I Got this error
Exception has occurred.
_Exception (Exception: Failed Load Data)
It's My Code Api
Future<List<Mosque>> getMahasiswaById(String id) async {
var baseURL=Urls.BASE_API_URL;
var apiRespon = await http.get('$baseURL/mahasiswa/get/id/$id');
if(apiRespon.statusCode == 200) {
final apiResponJson = json.decode(apiRespon.body);
print(apiResponJson);
return (apiResponJson['data'] as List).map((p)=>Mosque.fromJson(p)).toList();
} else {
throw Exception('Failed Load Data');
}
}
How can i fix this ? Thanks