Reputation: 25
Firebase v3.2.1 AngularFire 2.0.1
I try to set firebase, I got this error:
Error: Firebase.set failed: First argument contains undefined in property 'products.xxx.longDescFR'
but I cannot catch the error, no console log displayed!
firebase.database().ref('products').set(productList).then(function(ref) {
console.log(ref)
}).catch(function(error) {
console.log('Failed: ' + error);
});
any idea how to catch the reject/fail promise?
Chuck
Upvotes: 0
Views: 1415
Reputation: 598728
The catch()
clause is called when the write fails on the server, so when the security rules reject the operation.
When you're passing in undefined
, the operation already fails on the client. You could probably try catch
it, but it's way better to simply detect the undefined
and not write:
if (productList) {
firebase.database().ref('products').set(productList).then(function(ref) {
console.log(ref)
}).catch(function(error) {
console.log('Failed: ' + error);
});
}
Upvotes: 2