[英]AWS Amplify Amplify.configure(awsconfig) error
I am using the amplify cli with my NextJs app.我在 NextJs 应用程序中使用了放大 cli。 I feel like maybe I configured something wrong Im getting this error when trying to query data:
我觉得也许我配置了一些错误我在尝试查询数据时收到此错误:
[WARN] 32:17.454 DataStore - Data won't be synchronized. [警告] 32:17.454 DataStore - 数据不会同步。 No GraphQL endpoint configured.
未配置 GraphQL 端点。 Did you forget
Amplify.configure(awsconfig)
?您忘记了
Amplify.configure(awsconfig)
吗?
But I do have an aws-exports.js file.但我确实有一个 aws-exports.js 文件。 BUT i do see it sais awsmobile , im not to sure what else I might be doing wrong.
但我确实看到它是 awsmobile ,我不确定我可能做错了什么。
aws-exports file: aws 导出文件:
const awsmobile = {
aws_project_region: 'us-east-2',
aws_appsync_graphqlEndpoint:
private,
aws_appsync_region: 'us-east-2',
aws_appsync_authenticationType: 'API_KEY',
aws_appsync_apiKey:private,
}
As the warning suggests, you may want to check if Amplify.configure(awsconfig)
is called to set up the library in your project.正如警告所暗示的,您可能需要检查是否调用了
Amplify.configure(awsconfig)
来在您的项目中设置库。
For example, this is the example given in the official documentation.例如,这是官方文档中给出的示例。
// pages/index.js
import { AmplifyAuthenticator } from "@aws-amplify/ui-react";
import { Amplify, API, Auth, withSSRContext } from "aws-amplify";
import Head from "next/head";
import awsExports from "../src/aws-exports";
import { createPost } from "../src/graphql/mutations";
import { listPosts } from "../src/graphql/queries";
import styles from "../styles/Home.module.css";
Amplify.configure({ ...awsExports, ssr: true });
In your case, you may import awsmobile
from aws-exports.js
and call Amplify.configure({...awsmobile, ssr: true});
在您的情况下,您可以从
aws-exports.js
exports.js 导入awsmobile
并调用Amplify.configure({...awsmobile, ssr: true});
in your app's entry point.在您的应用程序的入口点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.