The Firebase "once" event does not resolve as a promise

According to the official Firebase documentation located at here, it states:

Return Value

Returns a Promise that can optionally be used instead of the successCallback and failureCallback to handle success and failure.

However, in my specific code example, I noticed that there is no promise being returned when calling the "once" function.

fb.once('value', function(snapshoot){
    snapshoot.forEach(function(snap){
    var book = new Book(snap);
    $scope.bookList.push(book);
    $scope.$apply();
  });
})
//Following lines below cause an error because no promise is returned.
.then(function(){
    console.log('promise called');
});

You can view the full code on jsfiddle: here

What am I doing wrong here? How can I make the "once" function return a promise?

Answer №1

Your current firebase version appears to be outdated. The documentation you are looking at mentions the 2.4.2 version, while you have an older version 1.0.11

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

Encountering a problem when attempting to execute Selenium

Currently, I am utilizing Ubuntu 12.04 and attempting to execute Selenium by running the command webdriver-manager start However, every time I try to run it, I encounter the following error message: webdriver-manager start seleniumProcess.pid: 3522 Exce ...

Angular-nvd3: maintaining consistent spacing between data points along the x-axis

By default, the scale of the x-axis is calculated from values, resulting in uneven distances between two adjacent points. For example, with an array of values like [1,2,5], there will be different distances on the x-axis for each point, and the x-axis labe ...

Issue: Undefined onClick function for HTML when using Node.js, NPM, and Parcel

I am currently working on a weather application using Node.js, NPM, and Parcel for development. To ensure OpenLayers functions properly, I need to incorporate these technologies, even though I'm not very familiar with them. One key aspect of my proje ...

Tips on customizing the appearance of mat-card-title within a mat-card

Is there a way to truncate the title of a mat card when it overflows? I tried using the following CSS: overflow:hidden text-overflow:ellipsis white-space: nowrap However, the style is being overridden by the default mat-card style. I attempted to use mat ...

The component data fails to reflect the updated value following a status change due to not properly retrieving the new result from the POST function

Below is the Vue.js 2 code snippet for sending data to the backend. The vuex library was used to manage the data status. After using the POST function, the result returned from the backend updates the value of sampleId. This value is auto-generated by the ...

What is the process for binding an absolute path instead of a relative path in a script that includes Node and Perl calls?

In my script, there is a function with the following code: def tokenize(latex,kind='normalize'): output_file = './out.lst' input_file = './input_file.lst' cmd = "perl -pe 's|hskip(.*?)(cm\\|in& ...

Align the Point SpotLight in the same orientation as the camera in Three.js for a flashlight effect

Just diving into this world and looking to create a basic 3D scene where I can navigate with PointerLockControls, but I also want to incorporate a flashlight. I've managed to get the spotlight to follow the camera, but its target is fixed at 0,0,0. A ...

Save the modal to a variable and display it when clicked

I am trying to create a modal and display it when a user clicks a button. However, I seem to be facing an issue where nothing happens when the button is clicked and there are no errors in the console. $( '.outlet' ).on('click', functio ...

What is the process for uploading a file with POST in angular?

What is the best way to send a pdf file without completely revamping our current system? I have explored various methods online, but most of them involve significant changes to our architecture, which is not ideal. Although I am not very experienced with ...

Before starting the operation, the beforeEach() function in the asynchronous Jasmine test is not being called

I'm currently coding a test for my client-server modules. One challenge I'm facing is that I need to ensure the server is running before the client sends its requests. To achieve this, I am attempting to utilize the beforeEach method. However, th ...

What is the method for displaying an array separately for each item in JSON using JavaScript?

The issue arises when using for (let pet of person.pets) loop. In my JSON data, the "pets" field is an array but instead of getting a single array for each object, I am getting all pet arrays for every object in the JSON file. The desired outcome is to h ...

The data extracted from JSON is not being refreshed

Here is the script: $(document).ready(function () { $.getJSON('table.json', function (data) { $('#mytable').empty(); var html = ''; html += '<tr class="tableheader">& ...

Javascript function encountering difficulty accessing the 'this' variable

I am embarking on a new HTML5 game project, my very first one. Right now, I am working on creating a function that holds variables. While I cannot recall its exact name, I remember the process from a tutorial. In my attempt to set up some of these variable ...

typescript: the modules with relational paths could not be located

As part of a migration process, I am currently converting code from JavaScript to TypeScript. In one of my files 'abc.ts', I need to import the 'xyz.css' file, which is located in the same directory. However, when I try to import it usi ...

Incorporate conditional components into a React state object

I have a variable called myVar that holds an array of values. I am trying to selectively add elements to the array based on a specific condition. For example: If the condition is met: myVar = [1, 2, 3] Otherwise: myVar = [1, 2, 3, 4, 5] In both cases ...

What is the most optimal method for converting an untyped array of 32-bit integers into a UInt8Array?

I have a standard JavaScript array filled with valid 32-bit signed integers that I need to convert into a UInt8Array. Take for example this JavaScript array: [255, 3498766, -99] The resulting UInt8Array should display the signed 32-bit representation of ...

NgMap is encountering an issue with an unfamiliar provider: NgMapProvider <- NgMap, raising a concern

While utilizing ngMap, it encountered an error. I have carefully reviewed all components and settings. Interestingly, it works flawlessly in one part of my application but not in the other. These two instances are located in separate file locations. ...

Strategies for Mitigating Duplicate Requests in AngularJs with just one click

I am facing an issue with my AngularJS application where clicking on a link triggers the API call twice. I'm not sure why this happens and how to fix it. My service: SomethingService function getData() { return apiSettings.getApiInformation().t ...

AngularJS: Error encountered when trying to assign a value to a read-only property in the ng-submit directive

I've been working on a personal project to practice angularJS, but I've encountered a problem that seems unsolvable to me. The issue arises when I try to utilize the submitLogin() function in my LoginCtrl.js file upon form submission. An error m ...

Tips for transferring a form using Ajax and PHP

Just starting out with this project and hoping for some help. I need to get a simple code working first before making any modifications. Currently, the echo function is not showing anything on the page after submitting the form. My goal is to submit a form ...