Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
open System.Net.Http
open System.Net.Http.Json
type Rate = { PLN: double }
type ApiResponse =
{ Amount: double
Base: string
Date: string
Rates: Rate }
let result =
async {
let client = new HttpClient()
let! result =
client.GetFromJsonAsync<ApiResponse>("https://api.frankfurter.app/latest?amount=10.99&from=USD&to=PLN")
|> Async.AwaitTask
printfn $"10.99 in USD is {result.Rates.PLN} in PLN"
}
result |> Async.RunSynchronously
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment