Hello, I am trying to using this library for my course study in university, and in the process I encountered a problem about retriving data by a post request. The format
fun login(name: String, password: String): Int {
var id = -1
Okkt.instance.Builder().setUrl("/user/findbyname")
.setParams(hashMapOf("name" to name)).get(object: CallbackRule<User> {
override suspend fun onFailed(error: String) {
Log.w("login", "name not found")
}
override suspend fun onSuccess(entity: User, flag: String) {
Log.w("login", "found password on server ${entity.password}")
if (password == entity.password) {
id = entity.userID // these lines are useless for id outside
}
else {
id = 0
Log.w("login error", "false password")
}
}
})
return id
}
Here I found that id cannot be assigned the value in the "onSuccess" block. How should I use the data retrived by the post request?
Hello, I am trying to using this library for my course study in university, and in the process I encountered a problem about retriving data by a post request. The format
Here I found that id cannot be assigned the value in the "onSuccess" block. How should I use the data retrived by the post request?