Second function is not working. It doesn't received the id that being passed from the first function.
Here is my JQuery code.
swal({
title: "Are you sure?",
text: "You will not be able to recover this record!",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm) {
if (isConfirm) {
// this.$http.delete();
window.axios.post(`/delete-sl-gl/${brcode}/${slc}/${slt}/${sle}/${cts}`)
.then(response => {
// console.log(response.data.sle)
if (response.data.success === true) {
swal('Deleted', response.data.message, 'success');
//console.log(response.data.sle)
spliceSLE_gl(sle.sle);
}
})
.catch(error =>{
console.log(error.response)
});
} else {
swal("Cancelled", "Your file is safe :)", "error");
}
I got an error / ignored in spliceSLE_gl(sle.sle);
A swal instance is a promise. To add functions based on user action, you have to use the
then()
method.Here is the structure of a swal with chained catch() and then() methods.