Is there a better way to make the front end kotlin...
# ktor
g
Is there a better way to make the front end kotlinJS talk to the backend Ktor than this:
image.png
Guess not?
Here is a tip: assign a type to remove the ?
Copy code
val content = document.getElementById("content") as HTMLElement
a
You code is not communication with the backend. Your ktor sever spits out
html
Then the
js
takes it from the client side and munipulate the
dom
Maybe you mean something different when you say you need
frontend
to communicate to the
backend
g
You are correct... It's just a little ugly. Wondering if there is a better approach
s
Not sure there is a better way to hydrate the frontend but at least you can do
Copy code
document.getElementById("content") ?: error("Couldnt find content element")
for better errors
g
That's an excellent suggestion, thanks, any others =) ...