Skip to content

Instantly share code, notes, and snippets.

@jciechowski
Created October 24, 2021 11:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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