我在我的NextJs应用程序中使用amplify cli。我觉得可能是我配置错了什么,我在尝试查询数据时遇到这个错误:
WARN 32:17.454 DataStore -数据将不会同步。未配置GraphQL终结点。你忘了Amplify.configure(awsconfig)了吗
但是我有一个aws-exports.js文件。但我确实看到它是可怕的,我不确定我可能还做错了什么。
aws-exports文件:
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,
}发布于 2021-09-30 10:05:27
正如警告所建议的,您可能希望检查是否调用了Amplify.configure(awsconfig)来在项目中设置库。
例如,这是官方文档中给出的示例。
// 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 });在您的示例中,您可以从aws-exports.js导入awsmobile,并在应用程序的入口点中调用Amplify.configure({...awsmobile, ssr: true});。
https://stackoverflow.com/questions/69380382
复制相似问题