[Vuejs]-Error in v-on handler: "auth is not a function" – Vue js

0👍

The following should do the trick:

fb.js

import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';

const firebaseConfig = {
  ....
};

firebase.initializeApp(firebaseConfig);

const db = firebase.firestore();
const auth = firebase.auth();


export { db, auth };

Component

<template>
 ....
</template>
<script>

const fb = require("fb.js");   // Adapt here depending on your folder structure, e.g. const fb = require("../fb.js");

export default {
    ...
    methods: {
        login(){
            fb.auth.signInWithEmailAndPassword(this.email, this.password)
            .then(...)
         // ...

};
</script>

Leave a comment