我需要将用户的数据发布到我的数据库(firebase)中,但是当我单击Touchable Opacity时,我的应用程序会返回以下错误: 单次发生 可能的未处理的承诺拒绝(id:0):TypeError:undefined不是对象(正在评估'res.data'
我的代码:
import {USER_LOGGED_IN, USER_LOGGED_OUT } from './actionTypes'
import axios from 'axios'
const authBaseURL ='https://www.googleapis.com/identitytoolkit/v3/relyingparty'
const API_KEY ='my api key is here'
export const login = user => {
return {
type: USER_LOGGED_IN,
payload: user
}
}
export const logout = () => {
return {
type: USER_LOGGED_OUT
}
}
export const createUser = user => {
return dispatch => {
axios.post (`${authBaseURL}/signupNewUser?key=${API_KEY}`, {
email: user.email,
password: user.password,
returnSecureToken:true
})
.catch(err => console.log(err))
.then (res => {
if (res.data.localId) {
axios.put(`/users/${res.data.localId}.json`, {
name: user.name,
tipouser: user.tipouser,
telcelular: user.telcelular,
telfixo: user.telfixo,
facebookuser: user.facebookuser,
instagramuser: user.instagramuser
})
.catch(err => console.log(err))
.then(res => {
console.log('Usuário criado com sucesso')
})
}
})
}
}
反应性:0.60.4 轴距:0.19.0 react-redux:7.1.1 redux:4.0.4“