Possible async issue that I need help with

Hello, I’m trying to use sweetalert2 for a project I’m working on and there seems to be some async issues (I think). Basically I’m trying to replace the browser popup that comes from the confirm() function because I need buttons that say something other than okay / cancel. Here is the code: https://pastebin.com/2eFfZt1c

basically what is happening if you look in the async part of the implementation, the else block is reached before the fireAlert() function brings up the sweetalert modal. It seems to me like sweetalert is using promises because of the .then() function in the fireAlert function. Just to let you all know I am a noob w/ javascript, I mostly do PHP programming. Thanks for the help!

Hi @mdference, yes that seems to be the case (I’m not really familiar with Swal myself though), however you’re not returning that promise from your fireAlert() function; so boolFlag will always be just undefined. So it should go like

function fireAlert (swalWithBootstrapButtons, e) {
  return swalWithBootstrapButtons.fire({
    // ...

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.