I've searched around but can't find a clear solution to my issue. I need help with implementing sweetalert
function in my component, specifically for data deletion using the service.
https://i.sstatic.net/o6W2n.png
Component
Swal({
title: 'Are you sure?',
text: 'You will not be able to recover this imaginary file!',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, keep it'
}).then((result) => {
if (result.value) {
this.bookingService.deletedata(data._id).subscribe(data => {
console.log(data);
});
Swal(
'Deleted!',
'Your imaginary file has been deleted.',
'success'
)
} else if (result.dismiss === Swal.DismissReason.cancel) {
Swal(
'Cancelled',
'Your imaginary file is safe :)',
'error'
)
}
})
Service
deletedata(param) {
console.log(param);
let searchUrl = Urlapi + '/pesan/remove' + param;
return this.http.delete(searchUrl, this.jwt()).map(res => res.json());
}