title: VueJS - Can not use keyword 'await' outside an async function
body: <p>I have this code and I am getting this error - &quot;Can not use keyword 'await' outside an async function&quot;:</p>
  <pre><code>async login() {
                  try {
                      this.$validator.validateAll().then((result) =&gt; {
                          if (result) {
                              this.state = 'LOADING';
                              this.response = [];
                              const authResponse = await axios.post('/api/auth/login', this.user);
                              const auth = authResponse.data;
  
                              if (auth.success) {
                                  this.$authLoggedIn(auth);
                                  this.$authRedirectToDefault();
                              } else {
                                  this.response.push(auth.error);
                                  this.state = 'ERROR';
                              }
                          }
                      });
                  } catch (error) {
                      this.state = 'ERROR';
                      this.response.push(error);
                  }
              },
  </code></pre>
  <p>How can I resolve this? Been stuck on this for a couple of hours.</p>
  <p>Thanks.</p>