I am trying to setup Paging 3 with Retrofit and I am unable to get past this call.
val response = redditAPI.getSubreddits(mBearer, mWhere, position, params.loadSize)
The getSubreddits
method is this
@GET("/subreddits/mine/{where}")
fun getSubreddits(
@Header("Authorization") bearer: String,
@Path("where") where: String,
@Query("after") after: String,
@Query("count") count: Int
): SubredditResponse
I have checked with a debugger and the inputs are exactly what I want.
A friend implemented this
@GET("{subreddit}/{filter}")
suspend fun getPostList(
@Path("subreddit") subreddit: String,
@Path("filter") filter: String,
@Query("after") after: String,
@Query("count") count: Int,
@Header("Authorization") bearer: String
): Listing
and he used this call
val response = redditAPI.getPostList(mSubreddit, mFilter, position, params.loadSize, mBearer)
and it works perfectly. I read that this error is related to the fact that Call
should be used as a return type but that is the way Paging 3 is set up with Retrofit and I can see no reason why it won't work. It's probably something stupid but I really cannot see what it is. The inputs from the other levels above this call are also correct, also checked with a debugger and all seem well.
Thank you in advance.
So, the problem was the missing
suspend
keyword before declaring the function. The Retrofit error was not helpful at all and I have little experience with Kotlin, so I had no idea thesuspend
keyword was that important. Lesson learned.