delete method

Future delete(
  1. String endPoint,
  2. Map data, {
  3. String? aUrl,
})

Implementation

Future<dynamic> delete(String endPoint, Map data, {String? aUrl}) async {
  String realUrl;
  final url = this._getOAuthURL("DELETE", endPoint);
  if (aUrl == null) {
    realUrl = url;
  } else {
    realUrl = url;
  }
  // final url = Uri.parse(baseUrl + "notes/delete");
  final request = http.Request("DELETE", Uri.parse(realUrl));
  request.headers.addAll(<String, String>{
    "Accept": "application/json",
  });
  request.body = jsonEncode(data);
  final response = await request.send();
  if (response.statusCode > 300)
    return Future.error(
        "error: status code ${response.statusCode} ${response.reasonPhrase}");
  final deleteResponse = await response.stream.bytesToString();
  _printToLog("delete response : " + deleteResponse.toString());
  return deleteResponse;
}