I'm trying to redirect the user to a URL, which seems like it should be simple. My code is quite straightforward:
Ok(url) => {
let params: HashMap<&str, &str> = HashMap::new();
if params.is_empty() {log::info!("Params is empty, which is proper");};
log::info!("Redirecting to {}", url.clone());
let redir_route = match Route::from_path(url.as_str(), ¶ms) {
Some(routable) => { routable },
None => {
log::info!("Failed to get route");
Route::Home
}
};
user_ctx_for_run_post.set_next(redir_route);
},
The source for from_path
appears to be simple:
Check to make sure that params is empty, then return a Routable object if so. If params is not empty, return None
. So I create the empty params
, make sure it's empty, then call from_path
and I get None
every single time.
Is there an easier way to do this? What's the appropriate way to do the JS equivalent of "window.location.href = ‘https://exampleURL.com/’;"
in Yew?
You can find web apis in web_sys.
The apis you're asking for, are in Window::location and Location::herf.
I hope this is what you're looking for.