如何更改 Firebase 中的错误消息?例如,输入无效密码时?
How can i change the error message in Firebase? For example, when invalid password is entered?
如何更改错误消息?我想找到一种方法来自定义此错误消息
这是我的登录方式
signInWithEmailAndPassword(auth, email, password)
.then((res) => {
dispatch({ type: “LOGIN”, payload: res.user });
setIsPending(false);
})
.catch((err) => {
setError(err.message);
});
无法更改 Firebase returns 的错误消息,但您可以检查错误代码,然后根据错误代码显示您自己的消息。
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 以了解您可能想要处理的内容。
如何更改错误消息?我想找到一种方法来自定义此错误消息
这是我的登录方式
signInWithEmailAndPassword(auth, email, password)
.then((res) => {
dispatch({ type: “LOGIN”, payload: res.user });
setIsPending(false);
})
.catch((err) => {
setError(err.message);
});
无法更改 Firebase returns 的错误消息,但您可以检查错误代码,然后根据错误代码显示您自己的消息。
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 以了解您可能想要处理的内容。