Impl Future<Output = Result<_, reqwest::Error>> doesn't implement Debug

How can i implement the debug trait for impl Future<Output = Result<_, reqwest::Error>>

        let client = Client::new();
        let response =

        println!("{:?}", response.json());

Add an .await


I get another error

type inside async fn body must be known in this context
cannot infer type for type parameter T declared on the associated function json

If you just want to print the response, use the text() method instead. The json() method requires that you specify what type you want to parse the json into.

1 Like

Awesome, Thanks it works.

But let's say i wanted parse it into a specific type how would i go about doing that, please could you give me an example?

use serde::Deserialize;

struct MyType {
    my_field: String,

let body: MyType = response.json().await.unwrap();


let body = response.json::<MyType>().await.unwrap();
1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.