Untitled

mail@pastecode.io avatar
unknown
dart
2 years ago
902 B
2
Indexable
Never
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;
  }