getGenres method

Future<List<Genre>> getGenres()

Implementation

Future<List<Genre>> getGenres() async {
  final response = await query('genre/movie/list', HttpMethod.get, constructQuery());

  if (response.statusCode == 200) {
    final List<Genre> genres = List<Genre>.from(response.data["genres"].map((x) => Genre.fromJson(x)));
    return genres.toList();
  } else {
    // If the server did not return a 200 OK response,
    // then throw an exception.
    throw Exception('Failed to load Genres');
  }
}