TayKangSheng/forem-api/1.0.0

ForemApi.Articles

This module allows you to make API calls to fetch a list of articles and decode it into an Elm records.

Definition

type alias QueryParameters =
{ username : Maybe String
, page : Maybe Int
, perPage : Maybe Int
, tag : Maybe String
, tags : Maybe (List String)
, tagsExclude : Maybe (List String)
}

A set of predefined query parameters used to fetch a list of articles.

Helper functions

blankQueryParameters : QueryParameters

Helper method to generate a blank set of QueryParameters

API calls

Config
-> QueryParameters
-> (Result Error (List Article) -> msg)
-> Cmd msg

Fetch a list of articles using a set of predefined filters represented by query parameters.

foremApiConfig : ForemApi.Config
foremApiConfig =
    ForemApi.Config
        "https://dev.to"
        [ Http.header "accept" "application/vnd.forem.api-v1+json" ]


queryParameters : QueryParamters
queryParameters =
    blankQueryParamters


cmd : Cmd msg
cmd =
    ForemApi.Articles.fetch
        foremApiConfig
        { queryParameters | tag = "elm" }
        msg