This module allows you to make API calls to fetch an article and decode it into an Elm records.
{ typeOf : String
, id : Basics.Int
, title : String
, slug : String
, socialImage : String
, description : String
, readingTimeMinutes : Basics.Int
, publishedAt : Time.Posix
, user : ForemApi.User.User
, bodyMarkdown : Maybe String
, bodyHtml : Maybe String
, tags : List String
, url : String
, canonicalUrl : String
}
Representation of an Article record from Forem API. All functions in this module should return an Article record.
fetch : ForemApi.Config -> Basics.Int -> (Result Http.Error Article -> msg) -> Platform.Cmd.Cmd msg
Fetch an article by article's ID.
foremApiConfig : ForemApi.Config
foremApiConfig =
ForemApi.Config
"https://dev.to"
[ Http.header "accept" "application/vnd.forem.api-v1+json" ]
cmd : Cmd msg
cmd =
ForemApi.Article.fetch foremApiConfig 1208487 msg
fetchBySlug : ForemApi.Config -> String -> String -> (Result Http.Error Article -> msg) -> Platform.Cmd.Cmd msg
Fetch an article using author's username and article's unique slug.
foremApiConfig : ForemApi.Config
foremApiConfig =
ForemApi.Config
"https://dev.to"
[ Http.header "accept" "application/vnd.forem.api-v1+json" ]
cmd : Cmd msg
cmd =
ForemApi.Article.fetchBySlug foremApiConfig "no_81" "1st-post-2a1" msg
articleDecoder : Json.Decode.Decoder Article
Decoder to decode article data from Forem Api into an Article record.