Tuesday 16 May 2017

Getting cannot read property of null for firebase

I have been wresting with this back and forth:

This is the current code for retrieving a path in firebase:

var refNew = db.ref('productSold/' + uid + '/' + productId + '/' + orderId);

    refNew.once('value', function(snapshot) {
        console.log("the sna " + snapshot.val());

        var newProductConfirmed = {
            title: snapshot.val().title,

I checked all the values being passed and they all show up. Also, the path on firebase exists like so:

productSold
            mgkHLtYwjaWMi7lePcKC8kD6yJm2
                       -Kk83j3h9tYVbq5BVNQE
                              asdadsad
                                 buyerId: "4kVnL4nMBgTqLCdz1VGWVDJe5bR2"
                                  title: "adsdsad"

However, when I call to grab the value the snapshot key does give me the order ID mentioned above asdadsad, but I keep getting this error:

FIREBASE WARNING: Exception was thrown by user callback. TypeError: Cannot read property 'title' of null. This is being handled by node js.

Appreciate on any insight.

Thanks



via Lion789

No comments:

Post a Comment