I have created a RegistrationRepositoryWorker class ```@HiltWorker class RegistrationRepositoryWorke...
m
I have created a RegistrationRepositoryWorker class
Copy code
@HiltWorker
class RegistrationRepositoryWorker @AssistedInject constructor(
    @Assisted private val appContext: Context,
    @Assisted private val workerParams: WorkerParameters,
    private val mylApi: MyApi,

) :
    CoroutineWorker(appContext, workerParams) {}
the code above fails with error Could not create Worker RegistrationRepositoryWorkerbut when I remove the MyApi from constructor it works well. How can I call the API correctly
Copy code
interface  MyApi{
    @POST("register") // Replace with the actual API endpoint
    suspend fun registerUser(@Body request: User): Response<ApiResponse>
}
a
Did you declared the instantiation of MyApi in module?
m
I had missed some implementation in the module. after following this article https://rahul9650ray.medium.com/dagger-hilt-retrofit-coroutines-9e8af89500ab
👍 1