Server function not working properly #1229
-
Hello, I'm pretty new to Leptos and Rust in general and I've run into a bit of a head-scratcher and Google isn't turning anything up for me... I had a basic skeleton working where I just had hard-coded #[server(GetFeeds, "/api")]
pub async fn get_feeds() -> Result<Vec<Feed>, ServerFnError> Now that I have this function to query my database, I'm using
Any help would be greatly appreciated, thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi! This is not quite enough information to understand what's going on. A few notes:
What's the nature of the question? Is there something that's not working in the app? Are you wondering why the POST request and hashes are used? A more full example might be helpful, especially for the server macro issue. |
Beta Was this translation helpful? Give feedback.
Just adding for the sake of knowledge and for any future readers: the reason it worked on initial load but not subsequently was that, during server-side rendering, server functions are actually just called directly on the server, as functions. The "registration" process is required to provide each one with a distinct URL that the server knows about, but these separate server function URLs are only used when a server function is called from the browser, not when it's called on the server (i.e., during server rendering.) So a server function worked properly on initial SSR of the page, but not if you navigated to it again from the browser.
As I mentioned, this registration is now done automa…