getUsers method
Retrieves a list of users from the API.
page
- The page number of the consultations to retrieve Defaults to 1.
perPage
- The number of consultations to retrieve per page Defaults to 20.
Returns a list of user objects if the API call is successful.
Implementation
Future<List<User>> getUsers({int page = 1, int perPage = 20}) async {
final response = await callApi(
perPage: perPage, page: page, endpoint: 'users', method: 'get');
if (response.statusCode == 200) {
final List<dynamic> responseData = json.decode(response.body);
final List<User> users =
responseData.map((json) => User.fromJson(json)).toList();
return users;
} else {
throw Exception(response);
}
}