Arquidev.Fetch
1.2.0
dotnet add package Arquidev.Fetch --version 1.2.0
NuGet\Install-Package Arquidev.Fetch -Version 1.2.0
<PackageReference Include="Arquidev.Fetch" Version="1.2.0" />
<PackageVersion Include="Arquidev.Fetch" Version="1.2.0" />
<PackageReference Include="Arquidev.Fetch" />
paket add Arquidev.Fetch --version 1.2.0
#r "nuget: Arquidev.Fetch, 1.2.0"
#:package Arquidev.Fetch@1.2.0
#addin nuget:?package=Arquidev.Fetch&version=1.2.0
#tool nuget:?package=Arquidev.Fetch&version=1.2.0
fetch
A minimal composable DSL for fetching JSON from HTTP (GET/POST).
NOTE: this IS NOT a general purpose HTTP client. If you need one, there are plenty to choose from. If you still want to use this and lack some features, use hack
to access underlying HttpRequestMessage
before sending.
It comes with builders allowing for sync (blocking) and async calls (both Task and Async variants):
fetch<'T>
- SyncfetchTask<'T>
- Task asyncfetchAsync<'T>
- F# asyncrq<'T>
- just the request - use it to create parts that can be used in thefetch*
builders
Examples
#r "paket: nuget Arquidev.Fetch ~> 1"
open Arquidev.Fetch
// POST with JSON body
let result = fetch<{|success: bool|}> {
POST "https://api.example.com/users"
Body {| name = "John"; email = "john@example.com" |}
Authorization "Bearer token123"
}
if result.success then ...
// hack it
let data = fetch<Data> {
GET "https://api.example.com/data"
hack (fun req -> req.Headers.Add("X-Custom", "value"))
}
Look at tests.fsx for more.
Composition
Note: the order of composition is important if the same element is specified in both rq and fetch - the last declaration wins
// compose it
let common = rq {
Authorization "Bearer token"
UserAgent "MyApp/1.0"
}
fetch<Data> {
GET "http://localhost"
common
}
Console logging
*NOTE: for full headers and request/response content set env var: FETCH_DEBUG=1
or in code Fetch.debugEnabled true|false
*
Fetch.enableLogs ()
//call(s) here
Fetch.disableLogs ()
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- FSharp.Core (>= 8.0.403)
- FSharp.SystemTextJson (>= 1.4.36)
- System.Text.Json (>= 8.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.