diff options
Diffstat (limited to 'src/api.rs')
-rw-r--r-- | src/api.rs | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -17,6 +17,7 @@ */ use reqwest; +use crate::station::{Station, StationContainer}; const API_BASE: &'static str = "https://oslobysykkel.no/api/v1"; @@ -40,9 +41,12 @@ impl Api { Api { client } } - pub fn stations(&self) -> String { - self.client.get(&url_for("stations")) + pub fn stations(&self) -> Vec<Station> { + let response_json = self.client.get(&url_for("stations")) .send().unwrap() - .text().unwrap() + .text().unwrap(); + + let v: StationContainer = serde_json::from_str(&response_json).unwrap(); + v.stations } } |