aws-amplify / aws-amplify/docs
[Gen2] Rest API setup will cause error "Subscribe only available for AWS AppSync endpoint"
- Dominant language
- MDX
- Stars
- 506
- Forks
- 1.1k
- Avg merge
- 3h 14m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
The code below will cause "Subscribe only available for AWS AppSync endpoint" when calling "client.models.Todo.observeQuery().subscribe" in react code.
```
import { Amplify } from 'aws-amplify';
import outputs from '../amplify_outputs.json';
Amplify.configure(outputs);
const existingConfig = Amplify.getConfig();
Amplify.configure({
...existingConfig,
API: {
REST: outputs.custom.API,
},
});
```
It can be fixed by adding line `...existingConfig.API` :
```
import { Amplify } from 'aws-amplify';
import outputs from '../amplify_outputs.json';
Amplify.configure(outputs);
const existingConfig = Amplify.getConfig();
Amplify.configure({
...existingConfig,
API: {
...existingConfig.API,
REST: outputs.custom.API,
},
});
```
Also warning message "warning "GraphQLAPI resolveConfig - The API configuration is missing"
**To Reproduce**
Steps to reproduce the behavior:
1. Create an amplify gen2 react-vite app following the quickstart: https://docs.amplify.aws/react/start/quickstart/
2. Add reset api follow this guide: https://docs.amplify.aws/react/build-a-backend/add-aws-services/rest-api/set-up-rest-api/#initialize-amplify-api
3. Then we get error "client.models.Todo.observeQuery().subscribe" when calling "client.models.Todo.observeQuery().subscribe"
**Expected behavior**
No error
**Screenshots**

**Desktop (please complete the following information):**
- OS: Windows
- Browser Chrome
**Additional context**
- Bug is also reported here: https://github.com/aws-amplify/amplify-js/issues/12986 by multiple developers, but I think it is also a doc issue need to be updated for Rest API setup.
Contributor guide
Assessment
This issue has not been assessed yet.