I have the following Vue.js app structure (src directory):
.
├── App.vue
├── assets
├── data
│ ├── config.js
├── main.js
├── router.js
└── views
└── app
├── index.vue
├── main
│ ├── dashboard.vue
│ └── index.vue
├── sessions
│ ├── index.vue
│ ├── login.vue
I already have implemented Firebase authentication, which works fine (refering to data/config.js). In my login.vue, I have the login form and a submit button:
<b-form @submit.prevent="formSubmit">
...
<b-button
type="submit"
...
which executes the formSubmit method:
<script>
...
methods: {
formSubmit() {
firebase
.auth()
.signInWithEmailAndPassword(this.email, this.password)
.then(data => {
this.$router.push('/app/main/dashboard').catch((err) => {
throw new Error(`${err}`);
});
})
.catch(err => {
console.log("not successful")
this.error = err.message;
alert(err.message);
});
},
},
...
</script>
As said, authentication works, I just don't get the redirect to the start page when successfully authenticated to work. Using the code above, I get
Uncaught (in promise) Error: undefined
in the browser inspector. I assume this has something to do with the this statement, but I'm running out of ideas how I can rewrite this to get a successful redirect. Does anybody has a hint for me?
Thanks!