Name:
interface
Value:
Amplify has re-imagined the way frontend developers build fullstack applications. Develop and deploy without the hassle.

Page updated Apr 29, 2024

Delete data

DELETE data

func deleteTodo() async {
let request = RESTRequest(path: "/todo")
do {
let data = try await Amplify.API.delete(request: request)
let str = String(decoding: data, as: UTF8.self)
print("Success: \(str)")
} catch let error as APIError {
print("Failed due to API error: ", error)
} catch {
print("Unexpected error: \(error)")
}
}
func deleteTodo() -> AnyCancellable {
let request = RESTRequest(path: "/todo")
let sink = Amplify.Publisher.create {
try await Amplify.API.delete(request: request)
}
.sink {
if case let .failure(apiError) = $0 {
print("Failed", apiError)
}
}
receiveValue: { data in
let str = String(decoding: data, as: UTF8.self)
print("Success \(str)")
}
return sink
}