Skip to content

Commit

Permalink
chore: refactor codes
Browse files Browse the repository at this point in the history
  • Loading branch information
itsyaasir committed Jan 28, 2024
1 parent 1687128 commit 32c11cd
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,21 +295,19 @@ impl Mpesa {
{
let url = format!("{}/{}", self.base_url, req.path);

let req = self
let res = self
.http_client
.request(req.method, url)
.bearer_auth(self.auth().await?)
.json(&req.body);

let res = req.send().await?;
.json(&req.body)
.send()
.await?;

if res.status().is_success() {
let body = res.json().await?;

Ok(body)
} else {
let err = res.json::<ResponseError>().await?;

Err(MpesaError::Service(err))
}
}
Expand Down

0 comments on commit 32c11cd

Please sign in to comment.