[Vuejs]-How do I retrieve the datas sent back to a SweetAlert2 Ajax call?

1👍

Swal returns a Promise, so make use of it in your delete function like that:

delete (title, text, type, confirmation, url) {
    let res = swal({
      // your code here ...
    });
    res.then(result => {
      // your code here ...
    })
    return res;
)

After that you could use it like this:

SweetAlert.delete(  // my initial code )
    .then(result => {
        if (result.value) {
            this.posts.splice(index, 1);
        }
    })
    .catch(error => {
        console.log('error', error)
    })
👤i–

Leave a comment