kbd
kbd

Reputation: 21

Firebase - need to fix javascript sdk auth error

I'm always getting this error:

TypeError: firebase.auth is not a function

Here is my code base, can some one help me plz?

const functions = require('firebase-functions');
var firebase = require("firebase/app");    

var firebaseConfig = {
  apiKey: "AIzaSyCGLNi4KMtUSC3CC3s6V-ZLQA87fDEuP-w",
  authDomain: "octatradesfirebasedemo.firebaseapp.com",
  databaseURL: "https://octatradesfirebasedemo.firebaseio.com",
  projectId: "octatradesfirebasedemo",
  storageBucket: "octatradesfirebasedemo.appspot.com",
  messagingSenderId: "889486380424",
  appID: "1:889486380424:ios:fb54696dc8f4a731df7e3d"
};

firebase.initializeApp({firebaseConfig});     
 console.log(firebase.auth);    
});

Upvotes: 0

Views: 80

Answers (2)

Frank van Puffelen
Frank van Puffelen

Reputation: 598740

If you want to use Firebase Authentication, you'll need to include firebase/app and firebas/auth.

var firebase = require("firebase/app");    
require("firebase/auth");    

That second require statement will add the firebase.auth() object.

Also see the Add Firebase SDKs and initialize Firebase section of the Firebase documentation.

Upvotes: 1

JoshM
JoshM

Reputation: 111

You are going to need to add <script src="/__/firebase/6.6.1/firebase-auth.js"></script> or <script defer src="https://www.gstatic.com/firebasejs/6.6.1/firebase-auth.js"></script> to your app

Upvotes: 0

Related Questions