Angularjs could not locate Firebase

I am creating an angularJS application and planning to implement Firebase for simple authentication.

Within my index.html file, I have added:

    <script src="https://cdn.firebase.com/js/simple-login/1.6.2/firebase-simple-login.js"></script>
    <script src="scripts/login.js"></script>

This is the current state of my login.js file:

$(document).ready(function(){
  var myRef = new Firebase("https://my_app.firebaseio.com");
  var auth = new FirebaseSimpleLogin(myRef, function(error, user) {
    if (error) {
      // an error occurred while attempting login
      console.log(error);
    } else if (user) {
      // authenticated user with Firebase
      console.log("User ID: " + user.uid + ", Provider: " + user.provider);
    } else {
       // user logged out
    }
  });
  var authRef = new Firebase("https://my_app.firebaseio.com/.info/authenticated");
  authRef.on("value", function(snap) {
    if (snap.val() === true) {
      alert("authenticated");
    } else {
      alert("not authenticated");
    }
  });
  auth.login('password', {
    email: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1d686e786f5d75">[email protected]</a>',
    password: 'password',
  });
  console.log(auth); 
});

My main goal with this code is to test the login functionality and examine the structure of the auth object post-login.

Future implementation involves integrating the login process into an ng-model to pass the data dynamically rather than hardcoded.

The issue currently encountered is that the code fails to execute, yielding an error in the JavaScript console:

Uncaught ReferenceError: Firebase is not defined 

What could be causing this problem?

Answer №1

You may be missing the essential firebase.js script in your code.

Having only the firebase-simple-login.js file won't suffice, as it depends on firebase.js.

<script src="https://cdn.firebase.com/js/client/1.0.17/firebase.js"></script>
<script src="https://cdn.firebase.com/js/simple-login/1.6.2/firebase-simple-login.js"></script>
<script src="scripts/login.js"></script>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What steps can I take to resolve the issue of item display in the dropdown menu?

My objective is to have a dropdown list with "title 1234" appearing first. When this option is selected, its value should be 1234. How can I achieve this? Here is the desired outcome: https://i.sstatic.net/CqWgn.png Currently, the list looks l ...

Leverage the variables' values to access property

There is a way to use this possibility: let eventSelected = "333"; let bestResult = result.personal_records[eventSelected]?.single?.best //like searching like this: result.personal_records.333?.single?.best However, when deali ...

Strange behavior of focus()

My objective is to launch a popup containing an input field and automatically bring focus to that input. I have attempted using $('#input').focus(), $('#input').first().focus(), and $('#input')[0].focus(), but unfortunately, ...

Searching for specific values within a date range in MongoDB, focusing on particular times of the day

I am working with a basic mongodb database that includes two key fields: date and value In my node project using mongoose, I have the following code to retrieve readings within a specific date range: Reading.find({ date: { $gte: startDate, $lt ...

Bug in canvas rendering for Chrome versions 94 and 95

The Canvas drawing functionality in the Chrome browser seems to have some visible bugs. Here's an example of code that demonstrates this issue: const canvas = document.getElementById('canvas'); const ctx = canvas.getContext('2d&apo ...

ExpressJS Node - .get switch to .route utilizing connect-ensure-login middleware

Considering that I have initially written a route using app.route: app.route('/word/:id') .get(word.getWord) .put(word.updateWord) .delete(word.deleteWord); Now, my aim is to modify the route by adding some middleware. While I am aw ...

The type 'Observable<unknown>' cannot be assigned to type 'Observable<Something>'

I am a beginner with Angular and Firebase, facing an issue while attempting to import of from rxjs and returning null using switchMap in my auth.service.ts. import { ActivatedRoute } from '@angular/router' import { Observable, of } from 'r ...

Mastering the art of seamless navigation within a single page through the magic of

I have two HTML pages: "Login.html" and "index.html". Instead of a normal href linking, I want the user to navigate to "index.html" when they click on the login button. Furthermore, I want the index page to be displayed within the codes of login.html, cre ...

What is causing the addListener function in the events class to malfunction?

I am a beginner in the world of node.js and attempting to execute this piece of code: var eventlib= require('events'); var emitter= new eventlib(); eventlib.addListener('MessageEvent', function() { console.log('Registered the ...

Ways to resolve the error message "TypeError: 'setOption' is not a function on type 'MutableRefObject' in React"

CODE export default function EChart({ option, config, resize }) { let chart = useRef(null) let [chartEl, setChartEl] = useState(chart) useEffect(() => { if (resize) { chartEl.resize() } if (!chartEl.cu ...

Error message: Node: TypeError - Attempted to access the 'sort' property of an undefined variable while using findOneAndUpdate() within a find() operation

My code snippet is shown below: var MongoClient = require('mongodb').MongoClient; MongoClient.connect('mongodb://localhost:27017/school', function(err, db) { if (err) throw err; db.collection('students').find().toArray( ...

Creating a persistent toolbar in Vuetify: Tips and tricks

Within my Vuetify app, I've implemented a toolbar: <v-toolbar dark color="primary"> <v-toolbar-side-icon @click.stop="drawer.drawer = !drawer.drawer"></v-toolbar-side-icon> <v-toolbar-title>{{drawer.title}}</v-toolb ...

I am having trouble with my jquery.ajax configuration where the async parameter is set to true. The data is not being sent back to

My goal is to save content whenever a button or hyperlink is clicked using jquery.ajax in an Asp.net 3.5 environment. Here is the logic I am following: I use .bind in jquery to attach my custom method(MakeLog) to a button click or hyperlink click. Sinc ...

"Enhanced interactivity: Hover effects and selection states on an image map

Hello there, I need assistance with my code. Here it is: <img id="body_image" usemap="#body_map" src="assets/images/body.jpg" alt=""> <map name="body_map"> <area shape="poly" alt="d" href="#body_chart" name="ad" coords="153, 153, 145, 1 ...

pass an array of document IDs from a Firebase collection to an endpoint

How can I retrieve only the names of the documents in the collection through the endpoint? import { db } from '../../lib/firebase'; export default async function handler(req, res) { const user = await db .collection('readings') ...

Ways to activate JavaScript on a completely dynamic AJAX ASP.NET website

Encountering a dilemma: I have developed a fully dynamic site with only one update panel on the startpage. All content is generated dynamically through code behind, with different pages as web user controls. The issue arises when attempting to open two d ...

Tips for successfully uploading FormData files using Axios: Resolving the TypeError of "file.mv is not a function"

When transmitting a file from one server to another using Axios, I am facing an interesting scenario where one server is an app backend and the other is a blockchain server. The destination for the file transmission is set up as follows: router.post("/a ...

bespoke theme background hue

I currently have material-ui@next installed and I am attempting to customize the background color of the theme. Here is what I have tried: const customizedTheme = createMuiTheme({ palette: createPalette({ type: 'light', primary: purple ...

Unable to locate the 'isDirectory' property of an undefined value

This code example is showcased in the book titled SMASHING Node.js:Javascript Everywhere. Despite following the steps and entering node index in the terminal, I encountered the following error message: Cannot read property 'isDirectory' of und ...

What is the best way to ensure that consecutive if blocks are executed in sequence?

I need to run two if blocks consecutively in TypeScript, with the second block depending on a flag set by the first block. The code below illustrates my scenario: export class Component { condition1: boolean; constructor(private confirmationServic ...