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
Hi, I want to use server_fn without leptos, just with axum and reqwest.
I tried to piece something together but am stuck.
When running this as a client i get a "Request("builder error")", and for the server I do not know how to use the handler.
Has anyone tried this, or is there an example?
use server_fn::ServerFnError;
use server_fn::client::reqwest::ReqwestClient;
use server_fn_macro_default::server;
#[tokio::main]
async fn main() {
#[cfg(feature = "client")]
main_client().await;
#[cfg(feature = "server")]
main_server().await;
}
#[cfg(feature = "client")]
async fn main_client() {
server_fn::client::set_server_url("127.0.0.1:8080");
// prints Err(Request("builder error"))
println!("{:?}", hello_world().await);
}
#[cfg(feature = "server")]
async fn main_server() {
let router = axum::Router::new().into_make_service();
// TODO: attach handler for hello_world
let listener = tokio::net::TcpListener::bind("127.0.0.1:8080")
.await
.unwrap();
axum::serve(listener, router).await.unwrap();
}
#[server(client = ReqwestClient)]
async fn hello_world() -> Result<String, ServerFnError> {
println!("I am the server");
"Hello, world!".to_string()
}
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
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I want to use server_fn without leptos, just with axum and reqwest.
I tried to piece something together but am stuck.
When running this as a client i get a "Request("builder error")", and for the server I do not know how to use the handler.
Has anyone tried this, or is there an example?
Beta Was this translation helpful? Give feedback.
All reactions