Why Do My Code Lines After Await Not Get Called?
Solution 1:
The returned Promise
from the firebase.login();
call should be wrapped within an async
function (which we cannot see from your snippet). As mentioned in the comments it's possible that the catch
is being triggered, in which case you should be gracefully handling the error.
// mock the firebase login Promiseconst firebase = {
asynclogin(email, password) {
return {
email
};
}
};
(async() => {
try {
const [email, password] = [
'joe.bloggs@example.com',
'password123',
];
const user = await firebase.login(email, password);
console.log(user);
} catch (err) {
console.error(err);
}
})();
Solution 2:
Answer :
I got the solution from my new hero:
"Submit buttons submit forms.
When a form is submitted, the browser navigates to a new web page.
Since the page the JS program was running in has been navigated away from, that JS program exits. It does this before reaching console.log("l2");"
So, everthing I had to do was insert "event.preventDefault". In the tutorial the used a simple Button, that does not cause the form to submit. I used a bootstrap submit-button und thats why I think the form was always submitted.
Post a Comment for "Why Do My Code Lines After Await Not Get Called?"