在Angular应用程序中,必须正确配置Amplify以使其能够访问配置对象中的所有必需属性。以下是可能的
import Amplify from 'aws-amplify'; import awsconfig from './aws-exports';
Amplify.configure(awsconfig);
const awsmobile = { "aws_appsync_graphqlEndpoint": "https://xxx.appsync-api.us-west-2.amazonaws.com/graphql", "aws_appsync_region": "us-west-2", "aws_appsync_authenticationType": "API_KEY", "aws_appsync_apiKey": "xxx", "aws_cognito_identity_pool_id": "us-west-2:xxx", "aws_cognito_region": "us-west-2", "aws_user_pools_id": "us-west-2_xxx", "aws_user_pools_web_client_id": "xxx", "oauth": {}, "aws_cloud_logic_custom": [ { "name": "MyApiName", "endpoint": "https://api.xxx.com", "region": "us-west-2" } ] };
如果仍然存在问题,请检查Amplify是否已经正确安装并重新启动应用程序。