I'm using fuel http to make a simple GET request. Here's my code:
fun fetchTweets(): List<Tweet> {
endpoint.httpGet(listOf("user" to "me", "limit" to 20))
.responseObject(Tweet.Deserializer()) { _, _, result ->
result.get().forEach { Log.i("TWEET", it.text) }
val tweets = result.get().toList() //I want to return this
}
}
If I do return tweets just below val tweets, I get an error:
return is not allowed here.
The makes sense to me. But the question still remains, how do I write a function that returns the variable created within the lambda? In this case, I want to return tweets