2

I'm trying to add authentication using Firebase in my Vue app, but I'm getting [Vue warn]: Error in v-on handler: "TypeError: _config_firebase__WEBPACK_IMPORTED_MODULE_8__.user.SignInWithEmailAndPassword is not a function" error. Here is my irebase config file:

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

const firebaseConfig = {
  apiKey: "MY_API_KEY",
  authDomain: "MY_AUTH_DOMAIN",
  databaseURL: "MY_DB_URL",
  projectId: "MY_PROJECT_ID",
  storageBucket: "MY_STORAGE_BUCKET",
  messagingSenderId: "MY_MESSAGE_SENDER_ID",
  appId: "MY_APP_ID"
};

// Initialize Firebase
firebase.initializeApp(firebaseConfig);

// Get a Firestore instance
export const user = firebase.auth();
export const db = firebase.firestore();

Then the action in Vuex:

import { db, user } from "./config/firebase";

 loginUser({ commit }, payload) {
      user
        .SignInWithEmailAndPassword(payload)
        .then(user => {
          console.log(user);
          commit("SET_USER", user);
        })
        .catch(error => {
          commit("setLoading", false);
          commit("setError", error);
          console.log(error);
        });
      router.push("/");
    }

So far, I have been able to Create, Read, Update and Delete, although, the config file was slightly different than this, when I added auth was when I altered the code.

0

1 Answer 1

1

Change this:

user.SignInWithEmailAndPassword(payload)

into this:

user.signInWithEmailAndPassword(payload)

From the docs:

Asynchronously signs in using an email and password.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.