HI i am new to using jetpack compose and in my code below i am trying to fetch data from a http request(a list of movies) and then adding each movie to the LazyColumnFor list(which is like a recyclerView)
HOwever, the list i pass to the LazyColumn is not compatibe and i get the following error:
lazyColumnFor Required:List<TypeVariable(T)>Found:List<MovieItem>?
Below is my composable function
@Composable
fun getTopMovies(){
val topMovies by movieListViewModel.getTopMovies().observeAsState()
LazyColumnFor(items = topMovies?.data?.results?)
}
THe API call i make using globalScope courotine
val result = MutableLiveData<Resource<DATA>>()
result.value = Resource.loading(null)
GlobalScope.launch {
try {
val response = client.await()
if (response.isSuccessful) {
val data = response.body() as DATA
result.postValue(Resource.success(data))
}
} catch (e: Exception) {
result.postValue(Resource.error(e.toString(), null))
}
THe movie list i return is below:
data class MovieList(val page: Int,
@SerializedName("total_results") val totalResults: Int,
@SerializedName("total_pages") val totalPages: Int,
val results: List<MovieItem>)