Within the promise attached to Firebase
's createUserWithEmailAndPassword()
function I'm trying to access a mutation function from my store, but I get the following error:
"TypeError: Cannot read property '$store' of undefined"
Why and how to solve this problem?
<script>
import firebase from 'firebase'
export default {
name: 'Signup',
data: function() {
return {
email: '',
password: ''
}
},
methods: {
signUp: function() {
firebase.auth().createUserWithEmailAndPassword(this.email, this.password).then(
function(user) {
alert('Your account has been created!');
this.$store.userConnectedUpdate('true');
},
function(error) {
alert('Oops. ' + error.message)
}
);
}
}
}
</script>