Hello guys! How can I get data from response heade...
# android
o
Hello guys! How can I get data from response header? I use Retrofit for network requests.
Copy code
@POST("api/auth/login")
    fun loginAsync(@Body loginRequest: LoginRequest): Deferred<LoginResponse>
Copy code
data class LoginResponse(
        val status: String
)
In my response I don't see it, but it exists. http://prntscr.com/nfty4z http://prntscr.com/nftylc
r
No need to make a
LoginResponse
object. Retrofit already has a
Response<T>
wrapper for any response that comes back with the status field you’re looking for
Copy code
@POST("api/auth/login")
    fun loginAsync(@Body loginRequest: LoginRequest): Deferred<Response<ResponseBody>>
Then you can just do
Copy code
val response = loginAsync(LoginRequest()).await()
response.headers()
o
yes, now this works fine, thank you! )
1