【问题标题】:AWS Amplify API does not existAWS Amplify API 不存在
【发布时间】:2021-05-03 20:20:57
【问题描述】:

我正在关注自动设置https://docs.amplify.aws/lib/restapi/getting-started/q/platform/js

我已经使用 Amplify UI 创建了数据模型并运行

amplify pull --appId XXXX --envName staging

我得到了

Successfully generated models. Generated models can be found in /dev/extension/vue-extension/src
Post-pull status:

Current Environment: staging

| Category | Resource name | Operation | Provider plugin   |
| -------- | ------------- | --------- | ----------------- |
| Api      | my_custom_name     | No Change | awscloudformation |

但是当我运行这段代码时

import Amplify, { API } from 'aws-amplify';
import awsconfig from '@/aws-exports';
Amplify.configure(awsconfig);

API.get('my_custom_name', '/rankings').then(items => console.log(items)).catch(e=> console.log(e ));

我明白了

API my_custom_name 不存在

【问题讨论】:

  • 我现在遇到了同样的错误。你有什么解决方法吗??
  • 不,我放弃了。如果您找到解决方案,请告诉我
  • 我刚刚从 amplify 中删除了 api 然后读取。它解决了我的问题。

标签: aws-amplify


【解决方案1】:

你的 import awsconfig from '@/aws-exports'; 看起来不正确。

尝试将其更改为import awsconfig from './aws-exports';

【讨论】:

    猜你喜欢
    • 2022-06-30
    • 2021-03-19
    • 2019-07-18
    • 1970-01-01
    • 2020-05-23
    • 2020-03-05
    • 2021-08-31
    • 2020-10-19
    • 2019-04-10
    相关资源
    最近更新 更多