This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
Make HTTP requests (download progress, rate-limit, debounce, throttle)
version 1.0.0
license BSD3
native-modules True
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.0
Committed At 2016-11-07 19:51:01 UTC
elm-lang/core 5.0.0 <= v < 6.0.0 5.1.1

README

HTTP in Elm

Make HTTP requests in Elm.

import Http
import Json.Decode as Decode


-- GET A STRING

getWarAndPeace : Http.Request String
getWarAndPeace =
  Http.getString "https://example.com/books/war-and-peace"


-- GET JSON

getMetadata : Http.Request Metadata
getMetadata =
  Http.get "https://example.com/books/war-and-peace/metadata" decodeMetadata

type alias Metadata =
  { author : String
  , pages : Int
  }

decodeMetadata : Decode.Decoder Metadata
decodeMetadata =
  Decode.map2 Metadata
    (Decode.field "author" Decode.string)
    (Decode.field "pages" Decode.int)


-- SEND REQUESTS

type Msg
  = LoadMetadata (Result Http.Error Metadata)

send : Cmd Msg
send =
  Http.send LoadMetadata getMetadata

Examples

Learn More

To understand how HTTP works in Elm, check out: