Created
October 24, 2021 11:39
-
-
Save jciechowski/0397ef73f889d7a652eb060bd51880d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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