blob: 4a2c6f0bba6c1c73c9f0fe42765f99d33629ae05 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
package webpage
import org.scalajs.dom
import org.scalajs.dom.{Node, Element}
import scala.scalajs.js
import scala.scalajs.js.annotation.JSExport
import scalatags.JsDom.all._
@JSExport
object Weather0 extends{
@JSExport
def main(target: dom.HTMLDivElement) = {
val xhr = new dom.XMLHttpRequest()
xhr.open("GET",
"http://api.openweathermap.org/" +
"data/2.5/weather?q=Singapore"
)
xhr.onload = (e: dom.Event) => {
if (xhr.status == 200) {
target.appendChild(
pre(xhr.responseText).render
)
}
}
xhr.send()
}
}
|