fetchAlbums method

Future<AlbumPaging> fetchAlbums (
  1. [String nextUrl]
)

Implementation

Future<AlbumPaging> fetchAlbums([String nextUrl]) async {
  String url = nextUrl ??
      '$_graphApiEndpoint/me/albums?access_token=$_accessToken&fields=cover_photo{source},id,name,count&format=json';
  http.Response response = await http.get(Uri.parse(url));
  Map<String, dynamic> body = json.decode(response.body);

  if (response.statusCode != 200) {
    throw GraphApiException(body['error']['message'].toString());
  }

  return AlbumPaging.fromJson(body);
}