hi, I'm trying to figure out Navigo, but I'm havin...
# kvision
a
hi, I'm trying to figure out Navigo, but I'm having trouble getting it working. When I click on a link, I always get
Cannot GET /servers/test-server
I've set up the routing...
Copy code
fun init() {
    routing
      .on("/", { _ ->
        println("routing.on HOME")
        homepageView()
      })
      .on("/servers/(.*)", { match ->
        println("routing.on SERVER $match")
        val serverId = match.data[0] as? String ?: error("invalid server id")
        println("routing.on SERVER serverId:$serverId")
        serverView(serverId)
      }
      )
      .resolve()
  }
And I think I'm creating the link correctly
Copy code
listTag(ListType.UL) {
        state.serverIds.forEach { serverId ->
          li {
            div {
              link(
                label = "$serverId",
                dataNavigo = true,
                url = "/servers/$serverId",
              )
            }
          }
        }
      }
I can see in the logs that Navigo seems to be aware of the routes, and is printing
routing.on HOME
, but it never prints
routing.on SERVER
Copy code
[WebsocketService] init <ws://localhost:3000/kafkatorio/ws>, 
kotlin-kotlin-stdlib-js-ir.js?46ac:19385 routing.on HOME
index.js?0118:551 [webpack-dev-server] Hot Module Replacement enabled.
index.js?0118:551 [webpack-dev-server] Live Reloading enabled.
kotlin-kotlin-stdlib-js-ir.js?46ac:19385 [WebsocketService.handleMessageEvent] non-json message elapsed 2h 53m 46.078512299s
test-server:1          GET <http://localhost:3000/servers/test-server> 404 (Not Found)
Navigated to <http://localhost:3000/servers/test-server>
I've tried using different matcher styles (regex, path IDs, plain strings) but nothing seems to work. A full example might help. The best example I've found was here: https://github.com/rjaros/kvision-realworld-example-app-fullstack/, but that's using the older version of Navigo. There's another usage in the KVision examples repo, but it's more simplistic.
I think I've fixed it by using the comment here https://kotlinlang.slack.com/archives/CL4C1SLKC/p1649134698139989?thread_ts=1649104695.886929&amp;cid=CL4C1SLKC
Copy code
main().bind(siteStateStore) { state ->
        div(className = "container-fluid") {
          when (state.view) {
            SiteView.HOME   -> homePage(state)
            SiteView.SERVER -> serverPage(state)
          }
        }
        window.setTimeout({ routing.updatePageLinks() }, 0)
      }
    }