Javascript 使用axios的Firebase auth rest api
我正在尝试将Firebase REST API与Rect本机项目上的Axios一起使用: 不管我做什么。。。我总是收到相同的错误:Javascript 使用axios的Firebase auth rest api,javascript,react-native,firebase-authentication,axios,Javascript,React Native,Firebase Authentication,Axios,我正在尝试将Firebase REST API与Rect本机项目上的Axios一起使用: 不管我做什么。。。我总是收到相同的错误: handleLogin = () => { //alert('trying to login....'); const onSuccess = ({ data }) => { alert('Success!!!!'); // Set JSON Web Token on suc
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,
错误:数组[
反对{
域名:全球,
消息:仅管理员操作,
原因:无效
有人知道我做错了什么吗,谢谢!如果有人需要这个 这里有一个问题:
const config = {
headers: {
'Content-Type': 'application/json',
},
};