I'd like to to pass a https string with an api key to Rust and print out the results of the GET request.
#[macro_use]
extern crate serde_json;
extern crate reqwest;
use reqwest::Error;
use std::future::Future;
#[derive(Debug)]
fn main() -> Result<(), Error> {
//Testing out pretty print JSON
let obj = json!({"data":{"updated_at":"2021-09-17T17:41:05.677631986Z","items":[{"signed_at":"2015-07-30T03:26:13Z","height":0}],"pagination":null},"error":false,"error_message":null,"error_code":null});
//Pretty print the above JSON
//This works
println!("{}", serde_json::to_string_pretty(&obj).unwrap());
//Issue API GET request
//Colon at the end of my_private_key is to bypass the password
let request_url = format!("https://api.xyz.com/v1/1/ -u my_private_key:");
let response = reqwest::get(&request_url);
println!("{:?}", response);
Ok(())
}
I receive the following output from the compiler.
--> src/main.rs:19:22
|
19 | println!("{:?}", response);
| ^^^^^^^^ `impl Future` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
= help: the trait `Debug` is not implemented for `impl Future`
= note: required by `std::fmt::Debug::fmt`
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)