gpt4 book ai didi

reactjs - 如何更改 Firebase 中的错误消息?例如,输入无效密码时?

转载 作者:行者123 更新时间:2023-12-05 04:34:52 24 4
gpt4 key购买 nike

Error Message

如何更改错误信息?我想找到一种方法来自定义此错误消息

这是我的登录方式

signInWithEmailAndPassword(auth, email, password)
.then((res) => {
dispatch({ type: “LOGIN”, payload: res.user });
setIsPending(false);
})
.catch((err) => {
setError(err.message);
});

最佳答案

无法更改 Firebase 返回的错误消息,但您可以检查错误代码,然后根据该错误代码显示您自己的消息。

signInWithEmailAndPassword(auth, email, password)
.then((res) => {
dispatch({ type: “LOGIN”, payload: res.user });
})
.catch((err) => {
if (err.code === "auth/") {
setError("The password you entered does not match to this user.");
}
else {
setError(err.message);
}
})
.finally(() => {
setIsPending(false);
});

查看完整 list of error codes了解您可能想要处理的内容。

关于reactjs - 如何更改 Firebase 中的错误消息?例如,输入无效密码时?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71151363/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com