You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am new to Leptos and trying to create a project using the axum template https://github.com/leptos-rs/start-axum (leptos 0.7)
I want to be able to access state from my server function and from following the documentation I have tried to add context to my leptos_routes in my main method:
I have a simple server function where I am trying to use the AppState that I have provided as context:
Which I am calling from a button click event in spawn_local.
However, when I call the server function may application panics as it does not find the expected AppState.
I have tried adding my own route service handler to target the "/api/create" endpoint as the documentation for the #[Server] macro says that we need to add context in handle_server_fns_with_context as well
However, my server will then not start as I am trying to register the same route twice. Looking at the source code for leptos_routes_with_context it seems that handle_server_fns_with_context is being called for all the server_fn_paths in that method.
Any help on what I might be doing wrong when trying to provide_context to my server function?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am new to Leptos and trying to create a project using the axum template https://github.com/leptos-rs/start-axum (leptos 0.7)
I want to be able to access state from my server function and from following the documentation I have tried to add context to my leptos_routes in my main method:
I have a simple server function where I am trying to use the AppState that I have provided as context:
Which I am calling from a button click event in spawn_local.
However, when I call the server function may application panics as it does not find the expected AppState.
I have tried adding my own route service handler to target the "/api/create" endpoint as the documentation for the #[Server] macro says that we need to add context in handle_server_fns_with_context as well
However, my server will then not start as I am trying to register the same route twice. Looking at the source code for leptos_routes_with_context it seems that handle_server_fns_with_context is being called for all the server_fn_paths in that method.
Any help on what I might be doing wrong when trying to provide_context to my server function?
Beta Was this translation helpful? Give feedback.
All reactions