Hey guys i need your help here am working on rxjav...
# android
k
Hey guys i need your help here am working on rxjava 2 with Kotlin and the call is keep calling on error with - HTTP 400 Bad Request
Copy code
disposable!!.add(service.login(user)
            .subscribeOn(<http://Schedulers.io|Schedulers.io>())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe({ response ->
                handleResponse(response)

            }, { error ->
                Tools.log("Error ${error.message}")
                handlerError(error)
                register_progress!!.dismiss()

            })
        )
My problem i keep gettting on error … even if the call is successful ….i get null
g
Get null where?
I didn’t get, do you have 400 and onError, or success and null (but not sure where, because RxJava2 doesn’t allow emit null)?
k
@gildor when i make a call on error is being called .. i expect response -> to be called because i have a check there I do a check like this on response :
Copy code
if (login.success) {
            //save the details
            Apps.pref.token = login.token
            //save into the local DB
        

            saveDetails(login)
        } else {
            //display a message
          //  error message here


        }
do u know why
response
is not being called when the result false .. and i have a check there
g
on error is being called
And what is in this error? What is throwable type and message?
k
i log the message like this error.message then i get
HTTP 401 Unauthorized
i making a post
g
So, 401
you have HTTP error
I suppose you use Retrofit with RxJava2 adapter
if so, this is how RxJava2 adapter works, emits errors to RxJava onError callback
I still not sure what is you problem
k
Okay .. let me google and see … am using rxjava2 with retrofit … a
a
you can add logger to OKHttpClient to log request and response to your API
k
Yea