| 11 | const API_ENDPOINT: &str = "api/v1"; |
| 12 | |
| 13 | fn films_endpoint() -> String { |
| 14 | let window = web_sys::window().expect("no global `window` exists"); |
| 15 | let location = window.location(); |
| 16 | let host = location.host().expect("should have a host"); |
| 17 | let protocol = location.protocol().expect("should have a protocol"); |
| 18 | let endpoint = format!("{}//{}/{}", protocol, host, API_ENDPOINT); |
| 19 | format!("{}/films", endpoint) |
| 20 | } |
| 21 | |
| 22 | async fn get_films() -> Vec<Film> { |
| 23 | log::info!("Getting films {}", films_endpoint()); |