Skip to content

Instantly share code, notes, and snippets.

@c10r
Created April 3, 2021 00:33
Show Gist options
  • Save c10r/faff5dcb62e41b94a99e8fb3c0be32dd to your computer and use it in GitHub Desktop.
Save c10r/faff5dcb62e41b94a99e8fb3c0be32dd to your computer and use it in GitHub Desktop.
Making an API request in kotlin/js
val levelApi = window.fetch("$BACKEND_URL?level=$level")
.await()
val levelJson = levelApi
.json()
.await()
val partialLevel: Level = levelJson.unsafeCast<Level>()
val partialTubes = JSON.parse<Array<Array<String>>>(partialLevel.tubes as String)
val newLevel = Level(partialTubes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment