getObject method

Future getObject()

Get the object referred to by this AlgoliaObjectReference.

If the object does not yet exist, it will be created.

Implementation

Future getObject() async {
  assert(_objectId != null, 'You can\'t get an object without an objectID.');
  try {
    String url = '${algolia._host}indexes/$_index/$_objectId';
    Response response = await get(
      Uri.parse(url),
      headers: algolia._header,
    );
    Map<String, dynamic> body = json.decode(response.body);
    return AlgoliaObjectSnapshot.fromMap(algolia, _index, body);
  } catch (err) {
    return err;
  }
}