clearIndex method

Future clearIndex()

ClearIndex

Clear the index referred to by this AlgoliaIndexReference.

Implementation

Future clearIndex() async {
  assert(index != null, 'You can\'t clear an objects without an indexName.');
  try {
    String url = '${algolia._host}indexes/$index/clear';
    Response response = await post(
      Uri.parse(url),
      headers: algolia._header,
      encoding: Encoding.getByName('utf-8'),
    );
    Map<String, dynamic> body = json.decode(response.body);
    return AlgoliaTask._(algolia, index, body);
  } catch (err) {
    return err;
  }
}