[英]How can i change the error message in Firebase? For example, when invalid password is entered?
How can i change the error message?我怎样才能更改错误消息? I would like to find a way to customise this error message我想找到一种方法来自定义此错误消息
This is my sign in method这是我的登录方法
signInWithEmailAndPassword(auth, email, password)
.then((res) => {
dispatch({ type: “LOGIN”, payload: res.user });
setIsPending(false);
})
.catch((err) => {
setError(err.message);
});
There is no way to change the error message that Firebase returns, but you can check the error code and then show you own message based on that.无法更改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);
});
See the full list of error codes to learn what you might want to handle.查看错误代码的完整列表以了解您可能想要处理的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.