Created
March 8, 2020 10:56
-
-
Save edgarfgp/33830d5a372f568b12958f6c9a0bc767 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
namespace DynamicUI | |
open DynamicUI.Models | |
open FSharp.Data | |
open FSharp.Json | |
module NetworkService = | |
let getMusicDataSearch (searchText: string option) = | |
async { | |
let term = | |
match searchText with | |
| Some value -> value | |
| _ -> "" | |
let urlString = sprintf "https://itunes.apple.com/search?term=%A" term | |
let! musicEntries = Async.Catch(Http.AsyncRequestString(urlString)) | |
let searchResult = | |
match musicEntries with | |
| Choice1Of2 musicList -> | |
let musicList = Json.deserialize<MusicList> musicList | |
Ok musicList.results | |
| Choice2Of2 error -> Error error | |
return searchResult | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment