I am trying to make utils for performing network operations in kotlin. I have below code where the primary constructor is taking Command and Context.
I am unable to access command variable in command.execute(JSONObject(jsonObj)), getting below error. I am not sure what is causing an issue?
Unresolved reference: command
class AsyncService(val command: Command, val context: Context) {
companion object {
fun doGet(request: String) {
doAsync {
val jsonObj = java.net.URL(request).readText()
command.execute(JSONObject(jsonObj))
}
}
}
}