问题描述
因此,我正在尝试使AWS Amplify的数据存储库与我正在构建的reactJS Web应用程序一起使用。我可以手动使用graphql突变向api发送数据或从api发送数据,然后尝试按照this tutorial设置DataStore。在使用索引数据库的客户端中,一切都工作正常,但是我无法获取与api同步的数据。我在控制台中收到以下错误:
DataStore - Data won't be synchronized. No GraphQL endpoint configured. Did you forget `Amplify.configure(awsconfig)`?
我仔细检查了一下,因此肯定包括了我的AWS导出:
import Amplify from "@aws-amplify/core";
import awsExports from "./aws-exports";
Amplify.configure(awsExports);
生成的./aws-exports.js
的内容如下:
/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "us-east-2","aws_appsync_graphqlEndpoint": "https://xxxxxxxxxxxxxx.appsync-api.us-east-2.amazonaws.com/graphql","aws_appsync_region": "us-east-2","aws_appsync_authenticationType": "API_KEY","aws_appsync_apiKey": "xxxxxxxxxxxxxx","aws_cognito_identity_pool_id": "us-east-2:xxxxxxxxxxxxx","aws_cognito_region": "us-east-2","aws_user_pools_id": "us-east-2_xxxxxxxxx","aws_user_pools_web_client_id": "xxxxxxxxxxxxxxxxxx","oauth": {}
};
export default awsmobile;
我已经仔细检查了aws_appsync_graphqlEndpoint
和aws_appsync_apiKey
的凭据,它们与cli中从amplify status
返回的值相匹配。我还运行了amplify push
,并且Api的状态为No Change
。设置api时,我确保也按照教程中的说明启用了冲突解决方法。
有趣的是,我在设置放大时还尝试了以下方法:
import Amplify from "@aws-amplify/core";
import {DataStore} from "@aws-amplify/datastore";
import awsExports from "./aws-exports";
Amplify.configure(awsExports);
DataStore.configure(awsExports);
这解决了DataStore - Data won't be synchronised
错误,但我收到了以下错误,并且数据仍未发送到api。
DataStore - subscriptionError Subscribe only available for AWS AppSync endpoint
DataStore - Sync error Subscribe only available for AWS AppSync endpoint
这是否表示我的API配置不正确?我该如何解决?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)