pub fn request(
client: &mut Client,
parameters: Map,
) -> Result<Dynamic, Box<EvalAltResult>>Expand description
Execute an HTTP request.
§Args
parameter: A map of parameters with the following fields:method: the method to use. (e.g. “POST”, “GET”, etc.)url: Endpoint to query.headers: Optional headers to add to the query, formatted as"Name: Value"strings.body: Optional body to add to the query.output: Output format:"text"(default) returns a String,"json"returns a Map.
§Errors
- The url failed to be parsed
- Headers failed to be parsed
- The request failed
§Example
let client = http::client();
let response = client.request(#{
method: "GET",
url: "http://example.com"
});
print(response)let client = http::client();
let response = client.request(#{
"method": "GET",
"url": "https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?slug=bitcoin&convert=EUR",
"headers": [
"X-CMC_PRO_API_KEY: xxx",
"Accept: application/json"
],
"output": "json",
});
print(response)