Computer scienceMobileAndroidNetworking

Networking Basics

Theory

Request

Report a typo

You have an interface:

interface ContactsApi {
    @GET("people.json")
    suspend fun getContacts(): Response<List<Contact>>
}

And a client with its implementation named client.

Get contents from the network in this code:

suspend fun getContacts(): Flow<ApiResponse> = flow {
    val response = // your answer here
    if (response.isSuccessful) {
        emit(response.body()!!)
    } else {
        emit(emptyList())
    }
}
Enter a short text

Create a free account to access the full topic