Can't fetch the data from my web app using React Native #14238
Labels
Core
Related to core Amplify issues
GraphQL
Related to GraphQL API issues
pending-maintainer-response
Issue is pending a response from the Amplify team.
question
General question
Before opening, please confirm:
JavaScript Framework
React Native
Amplify APIs
GraphQL API
Amplify Version
v6
Amplify Categories
api
Backend
Amplify CLI
Environment information
Describe the bug
I've used the Tanstack library (which @chrisbonifacio has recommended to me before instead of using datastore) to fetch the data from my already developed web app (which is deployed on aws amplify) but this library is not working well. Here is the code snippet and the message error I'm getting in the picture, and the graphql file which is the same one used in the web app:
Code Snippet:
import { generateClient } from 'aws-amplify/api';
import * as APITypes from '../API';
import { createUser } from '../graphql/mutations';
import { allUsers } from '../graphql/queries';
const client = generateClient();
export const createNewUser = async (userInput: APITypes.CreateUserMutationVariables) => {
try {
const response = await client.graphql({
query: createUser,
variables: userInput
});
} catch (error) {
console.error('Error creating user:', error);
throw error;
}
};
export const fetchAllUsers = async () => {
try {
const response = await client.graphql({
query: allUsers,
});
} catch (error) {
console.error('Error fetching users:', error);
throw error;
}
};
schema.graphql.zip
Expected behavior
If it worked, then it should use the graphql mutations and queries and make request using aws amplify.
Reproduction steps
Just use the code as I showed you before and it will give the error.
Code Snippet
Log output
aws-exports.js
/* eslint-disable */
// WARNING: DO NOT EDIT. This file is automatically generated by AWS Amplify. It will be overwritten.
const awsmobile = {
"aws_project_region": "us-east-2"
};
export default awsmobile;
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response
The text was updated successfully, but these errors were encountered: