Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elm/http
Make HTTP requests in Elm
https://github.com/elm/http
elm http
Last synced: about 1 month ago
JSON representation
Make HTTP requests in Elm
- Host: GitHub
- URL: https://github.com/elm/http
- Owner: elm
- License: bsd-3-clause
- Created: 2016-10-04T18:01:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2023-11-16T06:45:58.000Z (12 months ago)
- Last Synced: 2024-09-30T10:03:45.687Z (about 1 month ago)
- Topics: elm, http
- Language: Elm
- Homepage: https://package.elm-lang.org/packages/elm/http/latest
- Size: 59.6 KB
- Stars: 154
- Watchers: 15
- Forks: 46
- Open Issues: 29
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# HTTP
Make HTTP requests in Elm. Talk to servers.
**I very highly recommend reading through [The Official Guide](https://guide.elm-lang.org) to understand how to use this package!**
## Examples
Here are some commands you might create to send HTTP requests with this package:
```elm
import Http
import Json.Decode as Dtype Msg
= GotBook (Result Http.Error String)
| GotItems (Result Http.Error (List String))getBook : Cmd Msg
getBook =
Http.get
{ url = "https://elm-lang.org/assets/public-opinion.txt"
, expect = Http.expectString GotBook
}fetchItems : Cmd Msg
fetchItems =
Http.post
{ url = "https://example.com/items.json"
, body = Http.emptyBody
, expect = Http.expectJson GotItems (D.list (D.field "name" D.string))
}
```But again, to really understand what is going on here, **read through [The Official Guide](https://guide.elm-lang.org).** It has sections describing how HTTP works and how to use it with JSON data. Reading through will take less time overall than trying to figure everything out by trial and error!