如何从firebase Web检索特定数据

时间:2017-09-24 13:05:06

标签: javascript web firebase-realtime-database

firebase的json文件就像



{
  "users": {
    "a540678c0fda89f430bfba480ffe6f40146548bad72c199f8536b167fc58455a" : {
      "password" : "2a97516c354b68848cdbd8f54a226a0a55b21ed138e207ad6c5cbb9c00aa5aea",
      "phone" : "+91xxxxxxx",
      "uid" : "demo"
    }
  }
}




如何使用ref()获取密码,手机和uid的值。once()。then()语法

1 个答案:

答案 0 :(得分:0)

这应该有效:

var ref = firebase.database().ref("users/a540678c0fda89f430bfba480ffe6f40146548bad72c199f8536b167fc58455a");
ref.once("value").then(function(snapshot) {
  var user = snapshot.val();
  console.log(user.password, user.phone, user.uid);
});