apiGet method

Future apiGet(
  1. String url, {
  2. Map<String, String>? params,
  3. bool returnPayloadOnly = true,
})

Implementation

Future<dynamic> apiGet(String url, {Map<String, String>? params, bool returnPayloadOnly = true}) async {
  if (this.config != null && this.config.host != null) {
    // Maybe change this and uncomment below after Vasat2 search fixed and make sure behaves the same
    String queryParams = (params != null) ? params.entries.map((ele) => ele.key + "=" + ele.value).toList().join("&") : "";
    var uri = Uri.parse(this.config.host + url + ((queryParams.isNotEmpty) ? "?$queryParams" : "" ) );

    //var uri = Uri.parse(this.config.host + url);
    //if (params != null) uri = uri.replace(queryParameters: params);

    debug("apiGet URL: ${uri.toString()} With params: ${uri.queryParameters.toString()}");

    return http.get(uri, headers: getApiHeaders()).then((response) =>  processResponse(response, returnPayloadOnly));
  } else  {
    return Future.error(VasatError("No vasat configuration or host found", status: 8000));
  }

}