简体   繁体   English

如何从firebase获取用户列表

[英]how to get a list of users from firebase

function getUsersEmail() {
  const dbRef = ref(getDatabase());
  get(child(dbRef, `users/`  )).then((snapshot) => {
    if (snapshot.exists()) {
      console.table(snapshot.val());
    } else {
      console.log("No data available");
    }
  }).catch((error) => {
    console.error(error);
  });
}

I was able to output the database to the console.我能够将数据库 output 到控制台。 I would like to output only the email addresses of users.我想 output 只有用户的 email 地址。

JSON File JSON 文件

 {
"users": {
"2Le5WxOGnWWrkshsEqjeSIq527O2": {
  "email": "q5@gmail.com",
  "password": "qweqwe"
},
"2jn1YmI9twce3ylEP8wiu5QhUDf1": {
  "email": "55@gmail.com",
  "password": "qweqwe"
},

To retrieve all users and output only their email addresses:要检索所有用户和 output 仅他们的 email 地址:

get(child(dbRef, `users/`  )).then((snapshot) => {
  snapshot.forEach((child) => {
    console.log(child.val().email);
  })
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 javascript 从 firebase 获取活跃用户列表? - How to get active users list from firebase using javascript? 如何从 android 中 firebase 的图像列表中获取单个图像 - how to get single image from list of images from firebase in android 如何从 Firebase 实时数据库中获取数据到 Flutter 的列表中? - How to get data from Firebase Realtime Database into list in Flutter? 从身份验证列表中向 Firebase 上的所有用户发送 email - Send an email to all the users on Firebase from Authentication list 使用 flutter 从 firebase 获取集合列表 - Get list of collection from firebase using flutter Flutter Firebase中不同用户如何获取自己的数据? - How does different users get their own data in Flutter Firebase? Firebase:如何获取所有子节点的列表? - Firebase: How to get a list of all child nodes? 如何找到来自不同用户的 firebase 所有孩子的详细信息? - How to find firebase all children details from different users? firebase中如何给用户设置规则? - How to set rules to users in firebase? 如何从 firebase 存储中获取图像 URL 列表并将其上传到云 firestore? - How to get a list of image URL from firebase storage and upload it to cloud firestore?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM