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
Sam
10/03/2022, 6:33 PM
Not much to go on there my friend, what does your network handling code look like?
s
Sky
10/03/2022, 6:44 PM
PostFavourite:
data class PostFavourite(val image_id: String, val sub_id: String)
suspend fun postFavourite(postBody: PostFavourite) {
catsRemoteDataSource.postFavourite(postBody)
}
Sky
10/03/2022, 6:44 PM
@Sam
s
Sam
10/03/2022, 6:47 PM
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
Sky
10/03/2022, 6:52 PM
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
Sam
10/03/2022, 6:55 PM
In that case you do need to specify a new data class for the return type 😇😇