Cannot serialize Observable

48 Views Asked by At

I'm using Retrofit, RxJava (or rather RxKotlin) and Moshi to do a simple GET request which would return a single instance of my data. I'm using RxJava3 if that matters.

I'm using coroutines to send a request so I can visualize the data. I'm getting error the following error:

java.lang.IllegalArgumentException: Cannot serialize abstract class io.reactivex.rxjava3.core.Observable

@GET("company/one")
suspend fun getOneCompany(): Observable<CompanyState>
object RetrofitClient {
    private const val BASE_URL = "http://10.0.2.2:3000/api/"

    private val moshi = Moshi.Builder()
        .add(KotlinJsonAdapterFactory())
        .build()

    private val retrofit: Retrofit = Retrofit.Builder()
        .baseUrl(BASE_URL)
        .addConverterFactory(MoshiConverterFactory.create(moshi))
        .addCallAdapterFactory(RxJava3CallAdapterFactory.create())
        .build()

    val companyServiceApi: CompanyService = retrofit.create(CompanyService::class.java)
}
data class CompanyState(
    val name: String,
    val image: String,
    val tags: List<String>,
    val phoneNumber: String,
)
0

There are 0 best solutions below