fetchAlbum function

Future<Album> fetchAlbum()

Implementation

Future<Album> fetchAlbum() async {
  final response = await http.get(Uri.parse(apiUrl));

  if (response.statusCode == 200) {
    return Album.fromJson(jsonDecode(response.body));
  } else {
    throw Exception('Failed to load album');
  }
}