Since post and get are asynchronous functions, you have to await them. What you currently do in main is just creating Futures, but not executing them. You need an executor like tokio or async-std to run your futures, e.g.:
[dependencies]
tokio = { version = "0.2", features = ["full"] }
(you might want to include less than full features for tokio to save compilation time and binary size, but I'm not totally sure what the minimum feature set for your case would be).
Edit: the Rust compiler also warns you about the fact that your Futures are unused:
warning: unused implementer of `std::future::Future` that must be used
--> src/main.rs:5:5
|
5 | post();
| ^^^^^^^
|
= note: `#[warn(unused_must_use)]` on by default
= note: futures do nothing unless you `.await` or poll them
Just a quick question when I run post and ask it to print out res, it doesn't seem to print out the body and only prints out the headers. How can I include the body?
Hi alice, when I try to add on .text() onto res in post it says that the method is not found, do I need to add something to my dependencies? Could you maybe include a code snippet example? Thank you.