Firebase getUserByEmail不返回用户信息

编程入门 行业动态 更新时间:2024-10-10 06:20:24

Firebase getUserByEmail不返回<a href=https://www.elefans.com/category/jswz/34/1766089.html style=用户信息"/>

Firebase getUserByEmail不返回用户信息

我想通过getUserByEmail函数获取所有用户信息。但它返回[[Object Object]

也许我做错了。我只需要通过用户电子邮件获取用户displayNamephotoURL

我的Node.js

exports.getUserInfo = functions.https.onCall((data, context) => {

    if (context.auth.token.admin !== true) {
        return {
            message: 'permission denied. Admin role require'
        }
    }
    return admin.auth().getUserByEmail(data.email)
        .then(function (userRecord) {
            return {
                message: 'Successfully fetched user data:' + userRecord.toJSON()
            }
        })
        .catch(function (error) {
            return {
                message: 'Error fetching user data:' + error
            }
        });
});

我的Index.js

const updateForm = document.querySelector('#update-form');

updateForm.addEventListener('submit', (e) => {
    e.preventDefault();
    const email_st = document.querySelector('#update-email').value;

    const getUserInfo = functions.httpsCallable('getUserInfo');
    getUserInfo({
        email: email_st
    }).then(result => {
        console.log(result);
    });
});

console log

回答如下:

您需要对对象进行字符串化处理才能打印到控制台。

您可以按照以下步骤进行:

console.log(JSON.stringify(result));

如果要以某种格式打印它,则可以使用-

console.log(JSON.stringify(result, null, 4));

您可以阅读文档here了解更多详细信息。

更多推荐

Firebase getUserByEmail不返回用户信息

本文发布于:2024-05-07 15:31:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1756932.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:用户信息   Firebase   getUserByEmail

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!