fetchAll method

Future<NotionResponse> fetchAll({
  1. String? startCursor,
  2. int? pageSize,
})

Retrieve all databases.

A startCursor can be defined to specify the page where to start. Also a pageSize can be defined to limit the result. The max value is 100.

See more at https://developers.notion.com/reference/get-databases

Implementation

Future<NotionResponse> fetchAll({String? startCursor, int? pageSize}) async {
  Map<String, dynamic> query = {};
  if (startCursor != null) {
    query['start_cursor'] = startCursor;
  }
  if (pageSize != null && pageSize >= 0 && pageSize <= 100) {
    query['page_size'] = pageSize.toString();
  }

  http.Response res =
      await http.get(Uri.https(host, '/$v/$path', query), headers: {
    'Authorization': 'Bearer $token',
    'Notion-Version': dateVersion,
  });

  return NotionResponse.fromResponse(res);
}