post method

Future<Response> post({
  1. String path = '',
  2. Map<String, String>? headers,
  3. Map<String, dynamic>? params,
  4. Map<String, dynamic>? data,
})

Utility method to make a custom http post call with the Api Key added to the headers

Implementation

Future<Response> post({
  String path = '',
  Map<String, String>? headers,
  Map<String, dynamic>? params,
  Map<String, dynamic>? data,
}) async {
  // return await call('post', path: path, headers: headers, data: data);
  headers ??= {};
  headers.addAll({
    'content-type': 'application/json',
    'X-APIKEY': apiKey,
  });

  try {
    return await _client.post(_getUriUrl(basePath + path, params),
        headers: headers, body: json.encode(data));
  } catch (e) {
    if (e is HolodexException) {
      rethrow;
    }
    throw HolodexException(e.toString());
  }
}