fetchProvidersByAppId function

Future<List<ProviderV2>> fetchProvidersByAppId(
  1. String appId
)

Implementation

Future<List<ProviderV2>> fetchProvidersByAppId(String appId) async {
  try {
    final response = await http
        .get(Uri.parse('${Constants.GET_PROVIDERS_BY_ID_API}/$appId'));
    final res = json.decode(response.body);
    List<dynamic> rawProviders = res['providers']['httpProvider'];
    final providers = rawProviders.map((p) => ProviderV2.fromJson(p)).toList();
    return providers;
  } catch (err) {
    logger.e(err);
    throw Exception('Error fetching provider with AppId: $appId');
  }
}