getCountries method
Implementation
Future getCountries() async {
Response response;
final dio = apiClient();
try {
var data = dio.then((value) async {
response =
await value.post("documentConfig/getConfigCountryUserByDocId/");
var res = response.data;
if (res["isSuccess"]) {
var data = response.data['data'];
final results = List<Map<String, dynamic>>.from(data);
List<CountryModel> finalResult = results
.map((resultData) => CountryModel.fromMap(resultData))
.toList();
return finalResult;
} else {
throw 'Session expired, Try again';
// throw Exception(res["msg"]);
// exitInstaFido(context,ExitStatus.canceled,false,res["msg"]);
//return finalResult
}
});
return data;
} catch (e) {
throw "Something went wrong, try again";
}
}