title: show data's to a recyclerview from 2 different APIs. How to combine responses from 1st api and selected fields from 2nd API responses
body: <p>i have query related to multiple api calls .
  I need to show data's  to a recyclerview from 2 different API responses. How to combine all responses from  first api and  selected fields from 2nd API responses</p>
  <p>Eg : Api1 -  [{
  &quot;item_id : &quot;1&quot;,
  &quot;item_name&quot; : &quot;soap&quot;
  }]</p>
  <p><code>Api2-  [{ &quot;item_id : &quot;1&quot;, &quot;item_price&quot; : &quot;10&quot; </code>enter code here`}]
  enter code here</p>
  <p>Output like -
  Api1 -  [{
  &quot;item_id : &quot;1&quot;,
  &quot;item_name&quot; : &quot;soap&quot;,<code>enter code here</code>
  &quot;item_price&quot; : &quot;10&quot;</p>
  <p>}]</p>
  <p>My Android Classes:-</p>
  <p>Model Clasess</p>
  <pre><code> data class UsersData(
      @SerializedName(&quot;avatar&quot;)
      val avatar: String,
      @SerializedName(&quot;id&quot;)
      val id: Int,
      @SerializedName(&quot;name&quot;)
      val name: String,
      )
      enter code here
  
  data class PostData(
      @SerializedName(&quot;id&quot;)
      val id: Int,
      @SerializedName(&quot;body&quot;)
      val body: String,
      @SerializedName(&quot;title&quot;)
      val title: String,
  )
  data class SocialMediaData(
      @SerializedName(&quot;avatar&quot;)
      var avatar: String=&quot;default&quot;,
      @SerializedName(&quot;id&quot;)
      var id: Int=0,
      @SerializedName(&quot;name&quot;)
      var name: String=&quot;name&quot;,
      @SerializedName(&quot;body&quot;)
      var body: String=&quot;body&quot;,
      @SerializedName(&quot;title&quot;)
      var title: String=&quot;title&quot;,
  )
  </code></pre>
  <p>This is my viewmodel function</p>
  <pre><code>private fun fetchUsers() {
  
      val apikey = &quot;891B1ACC2262F7268DC688D48178C9D9&quot;
      viewModelScope.launch {
   /*       usersList.postValue(Resource.loading(null))
          postList.postValue(Resource.loading(null))*/
          allUsersFromApi.postValue(Resource.loading(null))
          try {
              // coroutineScope is needed, else in case of any network error, it will crash
              coroutineScope {
                  val usersFromApiDeferred = async { apiHelper.getUsersData(apikey) }
                  val moreUsersFromApiDeferred = async { apiHelper.getPostsData(apikey) }
  
                  val usersFromApi = usersFromApiDeferred.await()
                  val moreUsersFromApi = moreUsersFromApiDeferred.await()
  
  
                  Log.i(&quot;hfhf&quot;,&quot;&quot;+allUsersFromApi)
  
                  for (l1 in usersFromApi) {
                      for (l2 in moreUsersFromApi) {
                          if (l1.id == l2.id) {
  
                         /*     val searchHomeModel = SocialMediaData()*/
                              searchHomeModel.name = l1.name
                              searchHomeModel.avatar = l1.avatar
                              searchHomeModel.title= l2.title
                              searchHomeModel.name = l2.body
         
  
                              allUsersFromApi.postValue(searchHomeModel)
  
                          }
                      }
                  }
  
  
                /*  usersList.postValue(Resource.success(allUsersFromApi))
                  postList.postValue(Resource.success(allUsersFromApi))*/
              }
          } catch (e: Exception) {
              usersList.postValue(Resource.error(&quot;Something Went Wrong&quot;, null))
              postList.postValue(Resource.error(&quot;Something Went Wrong&quot;, null))
          }
      }
  }
  </code></pre>
  <p>Shows error in this line</p>
  <p>allUsersFromApi.postValue(searchHomeModel)</p>
  <p>arraylist.post() is not working.</p>
  <p>shows Type mismatch.
  Required:
  Resource&lt;List&gt;!
  Found:
  SocialMediaData</p>
  <p>Please help me</p>