我正在尝试使用 redux-thunk 在 firebase 中注册/添加用户。我正在尝试添加用户的电子邮件 ID 和密码。在提交时,我正在触发我的提交处理程序,在其中我正在调度一个动作“auth”,我的动作代码是:-
`export const SIGNUP ='SIGNUP';
export const signup = (email, password ) =>{
return async dispatch =>{
let response;
try{
response = await fetch('https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=[My-API-
Key]',
{
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: email,
password: password,
returnSecureToken: true
})
});
console.log(response)
} catch(e){
console.log(e);
}
// if(!response.ok){
// throw new Error('Something went wrong!');
// }
const resData = await response.json();
console.log(resData);
dispatch({type: SIGNUP});
}
};`
安慰错误时
Object { "error": Object { "code": 400, "errors": Array [ Object { "domain": "global", "message": "INVALID_EMAIL", "reason": "invalid", }, ], "message": "INVALID_EMAIL", }, }
提前致谢!!