AWS Amplify API does not exist

Viewed 724

I am followng the Automated setup https://docs.amplify.aws/lib/restapi/getting-started/q/platform/js

I have created the Data model using Amplify UI and run

amplify pull --appId XXXX --envName staging

and I got

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 |

but when I run this code

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 ));

I get

API my_custom_name does not exist

1 Answers

You're import awsconfig from '@/aws-exports'; looks incorrect.

Try changing it to import awsconfig from './aws-exports';

Related