Skip to main content

fetch

Function fetch 

Source
pub fn fetch<T: DeserializeOwned>(request: Request) -> Result<T, Error>
Expand description

Make a request and answer with its body.

Refuses a request with no URL before anything is sent.

use simpleplatform_sdk::http::{self, Method};

let answer: String = http::fetch(http::Request {
    url: "https://api.example.com/ping".to_string(),
    method: Method::Get,
    ..http::Request::default()
})?;

assert_eq!(answer, "pong");