Best way to capture error from database firebase javascript - Stack Overflow

I have this code, but i don't know how capture a error.const coleccionRef = database.ref('tes

I have this code, but i don't know how capture a error.

  const coleccionRef = database.ref('test');
  coleccionRef.on('value', snapshot => {
    snapshot.val();
  });

Any idea?

I have this code, but i don't know how capture a error.

  const coleccionRef = database.ref('test');
  coleccionRef.on('value', snapshot => {
    snapshot.val();
  });

Any idea?

Share Improve this question edited Dec 5, 2017 at 15:34 Frank van Puffelen 601k85 gold badges890 silver badges860 bronze badges asked Dec 5, 2017 at 11:09 allelallel 8771 gold badge12 silver badges22 bronze badges 1
  • 1 you may check that you have a data or empty with if(snapshot.exists()) { // do something with data } else {//there is no data} firebase.google./docs/reference/js/… – Cappittall Commented Dec 5, 2017 at 11:17
Add a ment  | 

1 Answer 1

Reset to default 8

If your client doesn't have permission to read from the reference, Firebase will invoke the (optional) second callback that you can pass in to on(). E.g.

const coleccionRef = database.ref('test');
coleccionRef.on('value', snapshot => {
  snapshot.val();
}, error => {
    console.error(error);
});

I remend reading the Firebase reference documentation for finding more tidbits like this.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744208511a4563223.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信