I am trying to use Sweetalert2 to validate inputs but I can't get it to work. The below code opens the pop-up then correctly identifies incorrect email addresses but the second swal doesn't appear if a correct one is entered, nothing happens.
(async function getEmail() {
const {value: email} = await swal({
title: 'Input email address',
input: 'email',
inputPlaceholder: 'Enter your email address'
})
if (email) {
swal('Entered email: ' + email)
}
])()
On further investigation I have found that if I remove the if argument, a pop up appears saying 'Entered email: undefined' so the actual email address isn't being passed.
I replaced const {value: email} = await
with const email = await
at which point it started to work