fetchUser method
Implementation
Future<Either<String, UserItemModel>> fetchUser(int id) async {
try {
final response = await http.get(Uri.parse('$baseUrl/$id'));
if (response.statusCode == 200) {
final data = jsonDecode(response.body);
return Right(UserItemModel.fromJson(Map<String, dynamic>.from(data)));
} else {
return Left('Error en obtener usuario: ${response.statusCode}');
}
} catch (e) {
return Left('Exception: $e');
}
}