get<T> static method

Future<T> get<T>(
  1. String url, {
  2. dynamic mapper(
    1. Map<String, dynamic>
    )?,
})

Implementation

static Future<T> get<T>(String url,
    {Function(Map<String, dynamic>)? mapper}) async {
  try {
    final response =
        await _client.get(Uri.parse(apiUrl + url), headers: headers);
    validateResponse(response);
    final jsonResponse = IApillonResponse.fromJson(jsonDecode(response.body));
    if (mapper != null) {
      return mapper(jsonResponse.data);
    }
    return jsonResponse.data;
  } on SocketException {
    throw ApillonNetworkError('No Internet connection');
  } on HttpException catch (e) {
    ApillonLogger.log(e.message, LogLevel.ERROR);
    throw ApillonRequestError(e.message);
  } on FormatException catch (e) {
    ApillonLogger.log(e.message, LogLevel.ERROR);
    throw ApillonRequestError(e.message);
  }
}