``` fun <DTO> IO<Response<DTO>>....
# arrow
p
Copy code
fun <DTO> IO<Response<DTO>>.withToken(accessToken: IO<AccessToken>): IO<Response<DTO>> =
  fx {
        val response = this@withToken.bind()
        val unwrapped = response.unwrapBody(IO.applicativeError()).fix()
        unwrapped.handleErrorWith { t ->
            if (t is HttpException && t.code() == 401) {
                accessToken.flatMap { this@withToken.withToken(HEREHEREHEREHERE) }
            } else {
                raiseError<Response<DTO>>(IllegalArgumentException()).fix()
            }
        }.fix().bind()
    }