apiPost method

Future apiPost(
  1. String url,
  2. Map<String, dynamic> payload, {
  3. bool returnPayloadOnly = true,
})

Implementation

Future<dynamic> apiPost(String url, Map<String, dynamic> payload, {bool returnPayloadOnly = true}) async {
  if (this.config != null && this.config.host != null) {
    debug("apiPost URL: ${this.config.host}${url} With body: ${jsonEncode(payload)}");
    return http.post( Uri.parse(this.config.host + url), body: jsonEncode(payload), headers: getApiHeaders(isJson: true))
        .then((res) => processResponse(res, returnPayloadOnly));
  } else  {
    return Future.error(VasatError("No vasat configuration or host found",status: 8000));
  }
}