I have set up a project with the React framework and simply want to show data on a Component. Everything works fine. My only problem is the the asynchronous API.graphQL function from @aws-amplify/api. I am using a typescript and want to work with classes.
Where should I solve the asynchronous, when I use classes?
Example:
//File showData.tsx
export default class ShowForm extends Component
render() {
//html
}
//File showData.tsx
export default class ShowForm extends Component
render() {
//html
}
componentDidMount(){
//read Data
Database.getForms("Id");
setState....
}
class Database.tsx
export default class DatabaseOperation{
getForms(formID): Form {
var test = (async function(){
call query)
//call api
list = await API.graphql(graphqlOperation(listForms, listQV));
....
}
return test.
}
I tried many things: created a real async method, handled the promises in a different way, ...
But when I debug it, I always end at the point, that it will return to the "NON ASYNC" method without finishing the async function. So I can not work with the data. I think I missed something.