我正在使用React,node.js和AWS cognito创建一个注册页面。处理注册事件时,出现错误'aws_amplify__WEBPACK_IMPORTED_MODULE_2 ___ default.a.signUp不是函数'
import Auth from "aws-amplify";
handleConfirmationSubmit = async event => {
event.preventDefault();
this.setState({ isLoading: true });
try {
await Auth.confirmSignUp(this.state.email, this.state.confirmationCode);
await Auth.signIn(this.state.email, this.state.password);
this.props.userHasAuthenticated(true);
this.props.history.push("/");
} catch (e) {
alert(e.message);
this.setState({ isLoading: false });
}
}
有关如何解决此错误的想法?
答案 0 :(得分:0)
将import Auth from "aws-amplify";
更改为import Auth from "@aws-amplify/auth";
答案 1 :(得分:0)
我刚刚从 import API from "aws-amplify";
改为 import { API } from "aws-amplify";