How do make an axios call inside sweet alert popup on dlete and show the data in dropdown inside popup?

I get popup showing are you sure you want to delet this data? But what i want is I want to make an axios call and fetch data inside that popup, asking where do you want to shift the data related to that data inside ? and show the dropdown?

deleteBeacon(beacon) {
      swal({
        title: "Are you sure?",
        text: "Do you really want to delete this beacon?",
        icon: "warning",
        buttons: true,
        dangerMode: true,
      })
        .then((willDelete) => {
          if (willDelete) {
            return axios.delete("/beacons/" + beacon.id);
          } else {
            swal("Cancelled", "Beacon is safe!", "error");
          }
        })
        .then((response) => {
          swal("Success", response.data.message, "success");
          this.beacons.splice(this.editedIndex, 1);
          this.closeDelete();
        })
        .catch((err) => {
          if (err.response.status == 401) {
            self.$router.push("/login");
          } else if (err.response.status == 404) {
            swal(
              "Error",
              "Beacon does not exists or has been recently removed!",
              "error"
            );
          }
        });
    },

This is my delete icon sweetalert popup,

axios.get(‘/beacons?centerId=’+this.form.center_id+’&without=’+this.$route.params.id)

This is the axios url to hit and fetch data, I want to show the data coming from hitting this url in that sweet akert popup

Source: Laravel

Leave a Reply