delete static method
Implementation
static Future delete(
String path, {
Object? payload = const {},
Map<String, dynamic>? qparams,
Uri? useUri,
String? serviceID,
}) async {
var client = http.Client();
try {
final response = await client.delete(
useUri ?? uri(path, queryparams: qparams, serviceID: serviceID),
body: jsonEncode(payload),
headers: _myHeaders(),
);
final decoded = json.decode(response.body);
if ((response.statusCode / 100).truncate() != 2) {
throw ApiErrorResponse(decoded["message"]);
}
return decoded["data"];
} catch (e) {
if (e is SocketException) throw ConnectionRefuted(err: e.message);
if (e is HttpException) throw ApiErrorResponse("Couldn't find the post 😱");
if (e is FormatException) throw RespuestaInvalida();
rethrow;
} finally {
client.close();
}
}