Advertisement
Guest User

Untitled

a guest
Feb 7th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.69 KB | None | 0 0
  1.     override fun componentDidMount() {
  2.         window.fetch("/api/hello")
  3.                 .then { response ->
  4.                     response.text().then { text ->
  5.                         setState {
  6.                             message = JSON.parse<HelloResponse>(text).message
  7.                         }
  8.                     }
  9.                      .catch {
  10.                          setState {
  11.                                     message = "error parsing json"
  12.                          }
  13.                      }
  14.                 }
  15.                 .catch {
  16.                     setState {
  17.                         message = "error fetch from Hello Service"
  18.                     }
  19.                 }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement