From a524cc2dcfc9ce7faa522c50273d4961c56df46e Mon Sep 17 00:00:00 2001 From: Giacomo Pasini <21265557+zeegomo@users.noreply.github.com> Date: Sat, 11 Nov 2023 16:49:18 +0100 Subject: [PATCH] use reqwest json() method (#525) --- nomos-cli/src/api/da.rs | 3 +-- nomos-cli/src/api/mempool.rs | 3 +-- nomos-cli/src/api/storage.rs | 7 +++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/nomos-cli/src/api/da.rs b/nomos-cli/src/api/da.rs index 35b4a9de..7a3d3c07 100644 --- a/nomos-cli/src/api/da.rs +++ b/nomos-cli/src/api/da.rs @@ -10,8 +10,7 @@ pub async fn get_blobs( const BLOBS_PATH: &str = "da/blobs"; CLIENT .post(node.join(BLOBS_PATH).unwrap()) - .header("Content-Type", "application/json") - .body(serde_json::to_string(&ids).unwrap()) + .json(&ids) .send() .await? .json() diff --git a/nomos-cli/src/api/mempool.rs b/nomos-cli/src/api/mempool.rs index 5ecc4e78..7c0d09da 100644 --- a/nomos-cli/src/api/mempool.rs +++ b/nomos-cli/src/api/mempool.rs @@ -9,8 +9,7 @@ where const NODE_CERT_PATH: &str = "mempool/add/cert"; CLIENT .post(node.join(NODE_CERT_PATH).unwrap()) - .header("Content-Type", "application/json") - .body(serde_json::to_string(cert).unwrap()) + .json(cert) .send() .await } diff --git a/nomos-cli/src/api/storage.rs b/nomos-cli/src/api/storage.rs index d7e8891a..75286556 100644 --- a/nomos-cli/src/api/storage.rs +++ b/nomos-cli/src/api/storage.rs @@ -10,12 +10,11 @@ pub async fn get_block_contents( block: &BlockId, ) -> Result>, reqwest::Error> { const BLOCK_PATH: &str = "storage/block"; - let block = CLIENT + CLIENT .post(node.join(BLOCK_PATH).unwrap()) - .body(serde_json::to_string(block).unwrap()) + .json(block) .send() .await? .json() - .await?; - Ok(block) + .await }