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
// If the future hasn't finished yet, we'll display a placeholder
41
41
// We use the wacky `&*` syntax to get the content of the `browser_ip` `Signal` and then we tell Rust to take a reference to that (we can't move it out because it might be used later)
42
-
let browser_ip_display = match&*browser_ip.get(){
42
+
let browser_ip_display = create_memo(cx, || match&*browser_ip.get(){
43
43
Some(ip) => ip.to_string(),
44
44
None => "fetching".to_string(),
45
-
};
45
+
});
46
46
47
47
view!{ cx,
48
48
p {(format!("IP address of the server was: {}", server_ip.get()))}
@@ -62,16 +62,22 @@ pub async fn get_build_state(
62
62
_locale:String,
63
63
) -> RenderFnResultWithCause<IndexPageState>{
64
64
// We'll cache the result with `try_cache_res`, which means we only make the request once, and future builds will use the cached result (speeds up development)
65
+
// Currently, target gating isn't fully sorted out in the latest version, so, because `reqwest` is only available on the server-side, we have to note that (in future, this won't be necessary)
66
+
#[cfg(not(target_arch = "wasm32"))]
65
67
let body = perseus::cache_fallible_res(
66
68
"ipify",
67
69
|| async{
68
70
// This just gets the IP address of the machine that built the app
69
-
let res = ureq::get("https://api.ipify.org").call()?.into_string()?;
70
-
Ok::<String,ureq::Error>(res)
71
+
let res = reqwest::get("https://api.ipify.org").await?.text().await?;
72
+
Ok::<String,reqwest::Error>(res)
71
73
},
72
74
false,
73
75
)
74
76
.await?;
77
+
// To be clear, this will never ever run, we just need it in the current version to appease the compiler (soon, this will be totally unnecessary)
0 commit comments