getUserById method

  1. @override
Future<Either<Failure, Map<String, dynamic>>> getUserById(
  1. int id
)
override

Implementation

@override
Future<Either<Failure, Map<String, dynamic>>> getUserById(int id) async {
  try{
    final response = await _dioClient.get('/users/$id');
    return Right(Map<String, dynamic>.from(response.data));
  }catch(e, stackTrace){
    if(e is Failure){
      return left(e);
    }
    return left(
      Failure(
        title: 'Error de gateway',
        code: 'gateway_error',
        description: e.toString(),
        stackTrace: stackTrace.toString(),
        type: FailureSeverity.blocking
      )
    );
  }
}