Skip to content

Http

Pipe-friendly HTTP functions that return Result natively. No try wrapper needed — errors are captured automatically.

FunctionSignatureDescription
Http.getstring -> Result<Response, Error>GET request
Http.poststring, unknown -> Result<Response, Error>POST request with JSON body
Http.putstring, unknown -> Result<Response, Error>PUT request with JSON body
Http.deletestring -> Result<Response, Error>DELETE request
Http.jsonResponse -> Result<unknown, Error>Parse response body as JSON
Http.textResponse -> Result<string, Error>Read response body as text
// Simple GET and parse JSON
const data = await Http.get("https://api.example.com/users")? |> Http.json?
// POST with a body
const result = await Http.post("https://api.example.com/users", { name: "Alice" })?
// Full pipeline
const users = await Http.get(url)?
|> Http.json?
|> Result.map((data) => Array.filter(data, .active))
// Error handling with match
match await Http.get(url) {
Ok(response) -> Http.json(response),
Err(e) -> Console.error(e),
}

All Http functions are async and return Result. Use await and ? for ergonomic error handling in pipelines.