I’m using an async function that awaits a GraphQL call. The GraphQL call returns a Promise that does contain the data I want. However, I’m unable to figure out a way to access it.
Here is the code:
export async function getModel() {
try {
const router = useRouter()
const {id} = router.query
console.log("id="+id)
const res = await API.graphql({
query: queries.getYawaraModel,
variables: {id: id}
})
return (
res
)
} catch (e) {
console.log("my error:"+e)
}
}
export default function Detail({props}) {
const technique = getModel()
console.log('technique', technique)
return <TechniqueListCard
Description={technique?.Description}
Technique={technique?.Name}
/>;
}
Here is a snapshot of the console log proving the payload data has been returned:
How do I access the contents of the returned Promise?