No description
Find a file
Yann Esposito 941bcc25bc Typo
2015-10-02 18:31:02 +02:00
src Typo 2015-10-02 18:31:02 +02:00
.gitignore Ignore elm-stuff/ directory 2015-04-09 09:54:41 -07:00
elm-package.json Add "elm-version" constraint 2015-03-23 18:34:47 -04:00
LICENSE Check in initial draft of elm-http 2015-03-08 15:36:39 -05:00
README.md Fix compile errors in example 2015-04-10 09:44:27 +02:00

elm-http

Make HTTP requests in Elm.

The Http module aims to cover some of the most common cases of requesting JSON data, but also have lower-level functions such that the API covers all of the underlying functionality.

Example

import Http
import Json.Decode as Json exposing ((:=))
import Task exposing (..)


lookupZipCode : String -> Task Http.Error (List String)
lookupZipCode query =
    Http.get places ("http://api.zippopotam.us/us/" ++ query)


places : Json.Decoder (List String)
places =
  let place =
        Json.object2 (\city state -> city ++ ", " ++ state)
          ("place name" := Json.string)
          ("state" := Json.string)
  in
      "places" := Json.list place