delete<_Model extends RestModel> method

  1. @override
Future<Response?> delete<_Model extends RestModel>(
  1. _Model instance, {
  2. Query? query,
  3. ModelRepository<RestModel>? repository,
})

Sends a DELETE request method to the endpoint

Implementation

@override
Future<http.Response?> delete<_Model extends RestModel>(instance, {query, repository}) async {
  final url = urlForModel<_Model>(query, instance);
  if (url == null) return null;
  logger.fine('DELETE $url');

  final resp = await client.delete(Uri.parse(url), headers: headersForQuery(query));

  logger.finest('#delete: url=$url statusCode=${resp.statusCode} body=${resp.body}');

  if (statusCodeIsSuccessful(resp.statusCode)) {
    return resp;
  } else {
    logger.warning('#delete: url=$url statusCode=${resp.statusCode} body=${resp.body}');
    throw RestException(resp);
  }
}