getProjects method

Future<List<Project>> getProjects()

Gets the project connected to the current user

Implementation

Future<List<Project>> getProjects() async {
  final path = '$_baseUrl/users/current/projects';
  final response = await _provider.get(
    path,
    headers: _defaultHeaders,
  );
  if (response.statusCode == 200) {
    final data =
        (jsonDecode(response.body) as Map<String, dynamic>)['data'] as List;
    return data.map((e) => Project.fromJson(e)).toList();
  }
  return [];
}