Fix stuff.
This commit is contained in:
parent
6485e0d24f
commit
0e7e0ae773
1 changed files with 3 additions and 5 deletions
|
@ -1,5 +1,4 @@
|
||||||
use serde::{Deserialize};
|
use serde::Deserialize;
|
||||||
|
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct Ip {
|
struct Ip {
|
||||||
|
@ -8,10 +7,9 @@ struct Ip {
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let resp = reqwest::get("https://api.ipify.org?format=json")
|
let resp = reqwest::get("https://api.ipify.org?format=json").await?;
|
||||||
.await?;
|
|
||||||
let body = resp.text().await?;
|
let body = resp.text().await?;
|
||||||
let ip: Ip = serde_json::from_str(&body)?;
|
let ip: Ip = serde_json::from_str(&body)?;
|
||||||
println!("My IP {}", ip.ip);
|
println!("{}", ip.ip);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue