Created
April 3, 2021 00:33
-
-
Save c10r/faff5dcb62e41b94a99e8fb3c0be32dd to your computer and use it in GitHub Desktop.
Making an API request in kotlin/js
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
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