Hi guys, i have a post request that returns: { ...
# android
s
Hi guys, i have a post request that returns: { “id”:“unique-id-of-the-new-favourite” } … so im wondering in order to get the return value do i need to create a new Kotlin data class?.. or can i just speicfy a return type…
s
Not much to go on there my friend, what does your network handling code look like?
s
PostFavourite:
data class PostFavourite(val image_id: String, val sub_id: String)
ImageService:
Copy code
@POST
suspend fun postFavourite(
    @Url url: String,
    @Body postBody: PostFavourite,
    @Query("api_key") api_key: String,
): Response<PostFavourite>
Repository:
Copy code
suspend fun postFavourite(postBody: PostFavourite) {
    catsRemoteDataSource.postFavourite(postBody)
}
@Sam
s
If your request type is the same as your response type the. Yes you can just reuse it, I think I may be misunderstanding your question though
s
this is the Post request type: { _“image_id”:“id of the image”,_ _“sub_id”:“optional unique id of your user”_ } and this is the Post request return type: { “id”:“unique-id-of-the-new-favourite” } @Sam
s
In that case you do need to specify a new data class for the return type 😇😇
s
ohh okay.. thanks alot @Sam