get method

  1. @override
Future<Map<String, dynamic>> get(
  1. String api,
  2. Map<String, dynamic>? headers,
  3. Map<String, dynamic>? params
)
override

Implementation

@override
Future<Map<String, dynamic>> get(String api, Map<String, dynamic>? headers,
    Map<String, dynamic>? params) async {
  try {
    final request = await _httpClient.getUrl(_makeUri(api, params));
    _addHeader(request, headers);
    request.headers.contentType = ContentType('application', 'json');
    final response = await request.close();
    if (response.statusCode == 200) {
      final responseBody = await response.transform(utf8.decoder).join();
      return json.decode(responseBody) as Map<String, dynamic>;
    }
    throw (response.statusCode);
  } catch (error) {
    rethrow;
  }
}