I'm currently facing an issue with my async function that awaits a GraphQL call. Even though the call returns a Promise containing the desired data, I'm struggling to access it effectively.
Below is the snippet of code in question:
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}
/>;
}
Additionally, I have a console log snapshot confirming the receipt of payload data:
https://i.sstatic.net/SOait.png
Would appreciate guidance on accessing the contents within the Promise returned by the GraphQL call.