Packages

I am playing with publishing a package.

Current section

Files

Jump to
playground src fetch.gleam
Raw

src/fetch.gleam

import gleam/http/request
import gleam/httpc
fn to_request(url: String) {
case request.to(url) {
Ok(base_req) -> base_req
Error(_) -> panic as "Something went wrong."
}
}
pub fn send_request(url: String) {
let req =
url |> to_request |> request.prepend_header("accept", "application/json")
case httpc.send(req) {
Ok(resp) -> resp
Error(_) -> panic as "Something went wrong."
}
}