Skip to content

Instantly share code, notes, and snippets.

@t4t5
Created September 6, 2017 14:30
Show Gist options
  • Save t4t5/730b44e10c7b56b26e86c1db534827e6 to your computer and use it in GitHub Desktop.
Save t4t5/730b44e10c7b56b26e86c1db534827e6 to your computer and use it in GitHub Desktop.
Using async with SweetAlert
const deleteFile = async () => {
// Wait for the user to press a button...
const shouldDelete = await swal("Delete file?", "Are you sure that you want to delete this file?", "warning");
if (shouldDelete) {
// Code to actually delete file goes here
swal("Poof!", "Your file has been deleted!", "success");
}
}
@clopezpro
Copy link

algun ejemplo para hacer funcionar

const {value: text} = await swal({
input: 'textarea',
inputPlaceholder: 'Type your message here',
showCancelButton: true
})

if (text) {
swal(text)
}

@talha08
Copy link

talha08 commented Nov 24, 2019

 async largeFileAlert (file) {
        try {
           const alert =  await Swal.fire({
                title: 'Are you sure?',
                text: `Warning, your image file is too heavy for this specific format.`,
                icon: 'warning',
                showCancelButton: true,
                confirmButtonText: 'Yes, Keep it!',
                cancelButtonText: 'No, Cancel it'
            });
           return !!(alert.value && alert.value === true);
        } catch (e) {
            console.log('error:', e);
            return false;
        }
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment