title: Suspend in coroutine in Kotlin is not waiting for answer from http request
body: <p>I need to wait for the http response so I can place it on my textview this is how I do it:</p>
  <p><strong>LoginFragment</strong></p>
  <pre><code>view.next_button.setOnClickListener {
              if (!isTextFieldCorrect(password_edit_text.text!!)) {
                  password_text_input.error = getString(R.string.shr_error_password)
                  username_text_input.error = getString(R.string.shr_error_username)
              } else {
                  next_button.isEnabled = false
                  password_text_input.error = null
                  username_text_input.error = null
                  val model = LoginModel(username_edit_text.text.toString().take(5), password_edit_text.text.toString().take(5))
                  apiService = api_service()
  
                  CoroutineScope(IO).launch {
                      var result: String? = apiService!!.login(model)
                      setTextOnMainThread(result.toString())
                  }
              }
  
  private fun setTextViewText(input: String) {
          val newText = input
          textView_status.text = newText
      }
      suspend fun setTextOnMainThread(input: String) {
          withContext(Main) {
              setTextViewText(input)
          }
      }
  </code></pre>
  <p><strong>apiService</strong></p>
  <pre><code>class api_service {
  
      var jsonPlaceholderApi: JsonPlaceholderApi? = null
  
      constructor() {
          var retrofit = Retrofit.Builder()
                  .baseUrl(&quot;http://192.168.1.8:5000/api/&quot;)
                  .addConverterFactory(GsonConverterFactory.create())
                  .build()
  
          jsonPlaceholderApi = retrofit.create(JsonPlaceholderApi::class.java)
      }
  
       suspend fun login(model: LoginModel): String? {
          var call: Call&lt;ResponseBody&gt; = jsonPlaceholderApi!!.login(model)
          var responseFromApi: String? = null
          if (!call.isExecuted) {
              call.enqueue(object: Callback&lt;ResponseBody&gt; {
                  override fun onFailure(call: Call&lt;ResponseBody&gt;, t: Throwable) {
                      responseFromApi = t.message
                      println(&quot;RESPONSE ${t.message}&quot;)
                  }
  
                  override fun onResponse(call: Call&lt;ResponseBody&gt;, response: Response&lt;ResponseBody&gt;) {
                      if(response.isSuccessful) {
                          val token = response.body()!!.string()
                          var tokenArr = token.split(':')
                          responseFromApi = tokenArr[1]
  
                      }
                  }
              })
          }
  
          return responseFromApi
      }
  }
  </code></pre>
  <p><strong>jsonPlaceholderApi</strong></p>
  <pre><code>interface JsonPlaceholderApi {
      @POST(&quot;auth/login&quot;)
      fun login(@Body model: LoginModel): Call&lt;ResponseBody&gt;
  }
  </code></pre>
  <p>I don't get any error and using the debug, it goes through the <code>setTextOnMainThread(input: String)</code> but it doesn't have any value in it. It looks like it gets to that part before the webapi gives a response.</p>