Created
June 15, 2016 14:20
-
-
Save anonymous/c1e2b441197fee44aaf4851efd9fb16e to your computer and use it in GitHub Desktop.
Scala.jsFiddle gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import util._ | |
import dom.ext._ | |
import scala.scalajs.concurrent.JSExecutionContext.Implicits.runNow | |
object ScalaJSExample extends js.JSApp{ | |
def main(): Unit = { | |
val url = | |
"http://jsonplaceholder.typicode.com/posts/1" | |
val f=Ajax.get(url) | |
f.onComplete{ | |
case Success(xhr) => | |
val json=js.JSON.parse(xhr.responseText) | |
val title=json.title.toString | |
val body=json.body.toString | |
println(div( | |
h1(title), | |
p(body)).render) | |
case Failure(e) => println(e.toString) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment