diff --git a/src/client.rs b/src/client.rs index be4f174..af44784 100644 --- a/src/client.rs +++ b/src/client.rs @@ -41,15 +41,15 @@ impl<'a> Client<'a> { pub async fn list_posts(&mut self, limit: Option, tags: Option>, page: Option) -> Result> { let mut url = url::Url::parse(format!("{}/posts.json", self.host).as_str())?; - let limit = limit.unwrap_or(320); - let page = page.unwrap_or(0); - let mut query_params = String::new(); - query_params.push_str("limit="); - query_params.push_str(limit.to_string().as_str()); + let mut query_params = Vec::new(); + if let Some(limit) = limit { + query_params.push(format!("limit={limit}")); + } - query_params.push_str("page="); - query_params.push_str(page.to_string().as_str()); + if let Some(page) = page { + query_params.push(format!("page={page}")); + } if let Some(tags) = tags { if tags.len() > 0 {