这个错误似乎给了你所有的信息。你有
()
在.catch块周围,它会警告您不能调用不是函数的东西。
axios({
method: 'post',
url: 'http://localhost:4000/login',
data: {
user_email: formData.user_email.value,
user_password: formData.user_password.value,
}
})
.then(res => res.json().then(user => ({ formData, res })))
.then(({ formdata, res }) => {
if (!res.ok) {
// If there was a problem, we want to
// dispatch the error condition
dispatch(Error(formdata.message))
return Promise.reject(formdata)
} else {
// If login was successful, set the token in local storage
localStorage.setItem('id_token', formdata.id_token)
localStorage.setItem('id_token', formdata.access_token)
// Dispatch the success action
// dispatch(formdata)
return Promise.resolve(res);
}
})
.then((result) => {
this.setState({
isLoaded: true,
items: result.items
});
})
.catch(err => console.log("Error: ", err))
另外,请在您的问题中添加一些关于您在问题中所面临的问题的相关信息,而不仅仅是将错误作为标题并提供代码。