【发布时间】:2020-08-29 13:35:51
【问题描述】:
我正在尝试在 Rect Native 项目上使用 Firebase REST API 和 Axios:
无论我做什么......我总是收到同样的错误:
handleLogin = () => {
//alert('trying to login....');
const onSuccess = ({ data }) => {
alert('Success!!!!');
// Set JSON Web Token on success
//setClientToken(data.token);
this.setState({ isLoading: false, isAuthorized: true });
navigation.navigate('Home');
};
const onFailure = (error) => {
alert('Error!!!!');
console.log(error && error.response);
this.setState({ errors: error.response.data, isLoading: false });
};
const signupUser = async () => {
try {
// set the url
const url =
'https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=.............';
// request data object
const data = {
email: this.state.email,
password: this.state.password,
returnSecureToken: true,
};
// set the headers
const config = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
};
const res = await axios.post(url, data, config);
console.log(res.data);
onSuccess(res.data);
} catch (err) {
console.error(err);
onFailure(err);
}
};
signupUser();
};
我总是收到带有相同响应的错误 400:
“代码”:400, “错误”:数组 [ 目的 { “域”:“全球”, "消息": "ADMIN_ONLY_OPERATION", “原因”:“无效”,
有人知道我做错了什么吗,谢谢!
【问题讨论】:
标签: javascript react-native firebase-authentication axios