getCountries method

Future getCountries()

Implementation

Future getCountries() async {
  Response response;
  final dio = apiClient();
  try {
    var data = dio.then((value) async {
      response = await value.post(UrlResources.countryList);
      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';
      }
    });
    return data;
  } catch (e) {
    throw "Something went wrong, try again";
  }
}