Skip to content

Instantly share code, notes, and snippets.

@anop72
Created August 6, 2018 05:07
Show Gist options
  • Save anop72/8fff5f3ffd1dec91f3e9609c6c133af3 to your computer and use it in GitHub Desktop.
Save anop72/8fff5f3ffd1dec91f3e9609c6c133af3 to your computer and use it in GitHub Desktop.
fuel-kotlin-refresh-token-test
private fun getData(): Single<String> {
var request: Request? = null
var response: Response? = null
var data: Any? = null
var error: FuelError? = null
var manager = FuelManager()
manager.basePath = "http://192.168.1.73:3000"
manager.addResponseInterceptor(validatorResponseInterceptor(200..500)
manager.addResponseInterceptor { loggingResponseInterceptor() }
return manager.request(Method.GET, "/happypath").response { req, res, result ->
var oldReq = req
var oldRes = res
when (result) {
is Result.Failure -> {
Single.create<String> { s -> s.onSuccess("error")}
// check 404 here
//and make request again
manager.request(Method.GET, "/endpoint that want to request for token").response { req, res, result ->
// handle here with `oldReq` send same request to old path
}
}
is Result.Success -> {
Single.create<String> { s -> s.onSuccess("error")}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment