Skip to content

Instantly share code, notes, and snippets.

@jciechowski
Created October 24, 2021 11:39
Show Gist options
  • Save jciechowski/0397ef73f889d7a652eb060bd51880d4 to your computer and use it in GitHub Desktop.
Save jciechowski/0397ef73f889d7a652eb060bd51880d4 to your computer and use it in GitHub Desktop.
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