You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Yann Esposito 941bcc25bc Typo 6 years ago
src Typo 6 years ago
.gitignore Ignore elm-stuff/ directory 7 years ago
LICENSE Check in initial draft of elm-http 7 years ago
README.md Fix compile errors in example 7 years ago
elm-package.json Add "elm-version" constraint 7 years ago

README.md

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