putRequest method

Future<Map> putRequest(
  1. String path,
  2. {Map<String, dynamic>? body}
)

Make put request to api

Returns Map of the response. Throws an ApiException if the request is unsuccessful.

Implementation

Future<Map> putRequest(String path, {Map<String, dynamic>? body}) async {
  final uri = getCausesApiPath(path);
  print(
      "Making request: ${uri.toString()}, body: $body, headers: ${getRequestHeaders()}");
  http.Response response = await client.put(
    uri,
    headers: getRequestHeaders(),
    body: json.encode(body),
  );

  if (response.statusCode >= 400) {
    throw getExceptionForResponse(response);
  }

  return await json.decode(response.body);
}