When using the firebase node library, the real time database, a promise is returned, but what happens if an exception happens in my code in the .then() method? How could I make the code go to the .catch() method? Here is the code that I am trying to make go to the catch method.
admin.database().ref('/something/something').once('value').then(function(data: admin.database.DataSnapshot) { if(data.val() === null) { return new TypeError('invalid'); } }).catch(function(err) { console.log(err); }); 