I want to know the difference between Call And Response ? That when to use Call & when to use to Response in Retrofit ?
@GET("/albums/{id}")
suspend fun functionOne(@Path(value = "id") albumsId:Int):Response<Albums>
@GET("/albums/{id}")
suspend fun functionTwo(@Path(value = "id") albumsId:Int):Call<Albums>
These both functions works fine for me, both have different implementations but have almost same purposes.
1. What way of response type is good for best practices ?
2. When to use Response & Call ?
1. What way of response type is good for best practices ?
I think it is depends on your use-case. By using
retrofit2.Response<T>, we can accesserrorBody()(The raw response body of an unsuccessful response.),code()(HTTP status code.) orheaders()(HTTP headers).2. When to use Response & Call ?
Call) replaced bysuspend function. Second method could be simpler like: