title: Retrofit2 enqueue onResponse() in Kotlin
body: <p>Function returns null before data.value is set in asynchronous onResponse().
  How to make it first fetch data and then return that data? </p>
  
  <pre><code>fun getNews(code: String): LiveData&lt;List&lt;News&gt;&gt;{
  
      val call = service.getNewsByCountry(code, Constant.API_KEY)
  
      var data = MutableLiveData&lt;List&lt;News&gt;&gt;()
  
      call.enqueue(object : Callback&lt;NewsResponse&gt; {
          override fun onFailure(call: Call&lt;NewsResponse&gt;?, t: Throwable?) {
              Log.v("retrofit", "call failed")
          }
  
          override fun onResponse(call: Call&lt;NewsResponse&gt;?, response: Response&lt;NewsResponse&gt;?) {
              data.value = response!!.body()!!.articles
          }
  
      })
  
      return data
  }
  </code></pre>