max pleaner max pleaner - 1 year ago 131
Javascript Question

Firebase is not setting data with browser API

Here's the code I have to set some data:


which returns

Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}

It suggests that I can pass it a then/catch handler, but writing:

log = function(x) {console.log(x)

has the exact same effect (nothing is returned/printed either way)

The wierd thing is that this intermittently works, I just can't figure out why.

Answer Source

.set and .update are both thenable.

function update(node,key,value){
    var ref = firebase.database().ref('/');
    var obj = {};
    obj[key] = value;
    .then(function() {
        console.log('Update Ran Successfully');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download