I'm using AWS Amplify v2.3.0 on Android Studio. Looking AWS documentation I can use Kotlin-Callback or Kotlin-Coroutines code. The callbacks call works for me. But the coroutines not working because IDE tell me that needs more parameters.
I need to use coroutines and not callbacks.For example, the sample AWS Code with callbacks works form me:
private fun getTodo(id: String) {
Amplify.API.query(ModelQuery.get(Todo::class.java, id),
{ Log.i("MyAmplifyApp", "Query results = ${(it.data as Todo).name}") },
{ Log.e("MyAmplifyApp", "Query failed", it) }
);
}
But the coroutine AWS sample code not works, because query function needs more parameters.
suspend fun getTodo(id: String) {
try {
val response = Amplify.API.query(ModelQuery.get(Todo::class.java, id))
Log.i("MyAmplifyApp", response.data.name)
} catch (error: ApiException) {
Log.e("MyAmplifyApp", "Query failed", error)
}
}
Anyone know what is happening?
Thank you so much!