{
"import": [
"mizchi/js",
"mizchi/js/web/http"
]
}fn main {
// Simple GET request
let response = @http.fetch("https://api.example.com/data")
// Create a Request
let request = @http.Request::new("https://api.example.com/users")
request.set_method("POST")
request.set_header("Content-Type", "application/json")
// Fetch with options
let init = @http.RequestInit::new()
init.set_method("POST")
init.set_body("{\"name\":\"value\"}")
let response2 = @http.fetch_with_init("https://api.example.com", init)
// Working with Headers
let headers = @http.Headers::new()
headers.set("Content-Type", "application/json")
headers.append("X-Custom-Header", "value")
// Working with FormData
let form = @http.FormData::new()
form.append("field", "value")
// Create Response
let response3 = @http.Response::new("body content")
}#external
pub type FormData#external
pub type Headerspub(all) struct Request {
bodyUsed : Bool
url : String
credentials : String
}pub struct RequestInit {
// private fields
}fn RequestInit::new(http_method? : String, headers? : Headers, body? : Any, mode? : String, credentials? : String, cache? : String, redirect? : String, referrer? : String, referrerPolicy? : String, integrity? : String, keepalive? : Bool, signal? : AbortSignal, priority? : String) -> RequestInitpub(all) struct Response {
ok : Bool
status : Int
statusText : String
redirected : Bool
}async fn fetch(url : String, method_~ : String, headers? : Map[String, String], cache? : String, mode? : String, body? : Any, credentials? : String, integrity? : String, keepalive? : Bool, priority? : String, redirect? : String, referrer? : String, referrerPolicy? : String, signal? : AbortSignal) -> Responsejs bindings for builtins/web/node/deno/bun (browser APIs split to mizchi/js_browser)
Dependencies