datasets method

Future<List<SanityDataset>> datasets()

Fetches the associated datasets with this project

Implementation

Future<List<SanityDataset>> datasets() async {
  final uri = Uri.parse(
    'https://api.sanity.io/${config.apiVersion}/projects/${config.projectId}/datasets',
  );

  final response = await httpClient.get(uri, headers: _requestHeaders);
  final datasets = (jsonDecode(response.body) as List<dynamic>)
      .map((json) => SanityDataset.fromJson(json as Map<String, dynamic>))
      .toList(growable: false);

  return datasets;
}