嗨,我有以下内容,并试图获取用户列表
exports.listAllUsers = functions.https.onCall((req, res) => {
// List batch of users, 1000 at a time.
return listAllUsers();
});
function listAllUsers(){
var allUsers = [];
return admin.auth().listUsers()
.then(function (listUsersResult) {
listUsersResult.users.forEach(function (userRecord) {
// For each user
var userData = userRecord.toJSON();
allUsers.push(userData);
});
res.status(200).send(JSON.stringify(allUsers));
})
.catch(function (error) {
console.log("Error listing users:", error);
res.status(500).send(error);
});
}
在网页中,调用时显示错误
$('#buttonID').click(function () {
var listAllUsers = firebase.functions().httpsCallable('listAllUsers');
listAllUsers({}).then(function(result) {
console.log(result);
});
});
任何想法