getProductById method

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

Implementation

@override
Future<Either<Failure,Map<String, dynamic>>> getProductById(int id) async {
  try{
    final response = await _dioClient.get('/products/$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(),
            type: FailureSeverity.blocking,
            stackTrace: stackTrace.toString()
        )
    );
  }


}