requestMap function

Future requestMap({
  1. required String endpoint,
  2. required MapResponseHandler responseHandler,
  3. dynamic params,
})

Implementation

Future requestMap({required String endpoint, required MapResponseHandler responseHandler, params}) async {
  var url = Uri.http('$localhostApiUrl:3000', endpoint, params);
  Response response = await get(url, headers: {"content-type": "application/json"});

  if (response.statusCode < 400) {
    if (kDebugMode) {
      print(response.body);
    }
    return responseHandler(response.body);
  }
  throw Exception(errorFromJson(response.body).error);
}