Why do my code lines after await not get called?

前端 未结 2 684
长情又很酷
长情又很酷 2021-01-26 10:41

I have a problem with the following code. The firebase.login returns a Promise and I learned that, when I put \"await\" before, Javascript waits until the Promise delivers and t

2条回答
  •  无人共我
    2021-01-26 10:54

    Solution:

    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.

提交回复
热议问题