request method

Future<Either> request(
  1. Method method,
  2. String route, {
  3. Map<String, String> params = const {},
})

Implementation

Future<Either> request(
  Method method,
  String route, {
  Map<String, String> params = const {},
}) async {
  Uri uri = _buildUri(route, params);
  try {
    await _makeRequest(method, uri);

    if (_response.statusCode == 200) {
      return Right(_response);
    } else {
      return Left(
        Failure(
          _response.statusCode,
          _response.body,
        ),
      );
    }
  } catch (e) {
    return Left(
      Failure(
        _response.statusCode,
        e.toString(),
      ),
    );
  }
}