Untitled

 avatar
unknown
dart
3 years ago
902 B
6
Indexable
Future<List<Address>> getAllAddresses() async {
    final AuthenticationManager authManager = Get.find();
    List<Address> list = [];

    try {
      await httpClient
          .get(baseUrl + 'Iktifaa/RequesterAddressBooks/GetAll',
              queryParameters: {
                'searchCriteriaModel.requesterId': authManager.appUser.value.id,
              },
              options: Options(headers: {
                'accept': 'application/json',
                'Content-Type': 'application/json',
                'Authorization': authManager.getToken(),
              }))
          .then((response) {
        if (response.statusCode == 200) {
          print(response.data);
          list = List<Address>.from(json
              .decode(json.encode(response.data['data']['items']))
              .map((x) => Address.fromJson(x)));
        }
      });
    } on DioError {}

    return list;
  }
Editor is loading...