# Elm and Http beginner

**URL:** <https://discourse.elm-lang.org/t/elm-and-http-beginner/8507>\
**Category:** Learn\
**Created:** [July 14, 2022, 8:54pm UTC](https://discourse.elm-lang.org/t/elm-and-http-beginner/8507 "2022-07-14T20:54:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mjt/32/4090_2.png) [@mjt](https://discourse.elm-lang.org/u/mjt)\
**Post date:** [July 14, 2022, 8:54pm UTC](https://discourse.elm-lang.org/t/elm-and-http-beginner/8507/1 "2022-07-14T20:54:37Z")

</div>

Good day.

Laid out by Covid here so I thought while I had a couple of spare days I’d learn Elm. Nice language and ecosystem!

Being more of a backend scientific programmer, I’m a beginner in the learn by simple example phase with Elm and also with Web apps and HTTP protocols. I’m using Elm 0.19 following this example [elm-with-jwt-api/Main.elm at step-2 · auth0-blog/elm-with-jwt-api · GitHub](https://github.com/auth0-blog/elm-with-jwt-api/blob/step-2/src/Main.elm)

It turned out that this example is not up to date with Elm 0.19 and uses the old Http 1 library (Http.send) rather than the ELM 0.19 Http 2 library (Http.post) which has brought too many unknowns into the easy learn by example paradigm.

Do you know of a simple online web app example online which uses HTTP 2 Http.post to do a simple Username/Password authentication, returning a JWT token, and then posting a query to an API using that token?

Thanks in advance,

Mike

---

<div class="post-metadata">

**Author:** ![klaftertief](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/klaftertief/32/5338_2.png) [@klaftertief](https://discourse.elm-lang.org/u/klaftertief)\
**Post date:** [July 15, 2022, 7:06am UTC](https://discourse.elm-lang.org/t/elm-and-http-beginner/8507/2 "2022-07-15T07:06:50Z")

</div>

[GitHub - rtfeldman/elm-spa-example: A Single Page Application written in Elm](https://github.com/rtfeldman/elm-spa-example) is a good resource for a lot or real word functionality in Elm apps. Hopefully it’s simple enough. There are many things inside.

Have a look at the `Api` module there for post requests and how its used in `Page.Register`

---

<div class="post-metadata">

**Author:** ![novid](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/novid/32/4341_2.png) [@novid](https://discourse.elm-lang.org/u/novid)\
**Post date:** [July 15, 2022, 9:58am UTC](https://discourse.elm-lang.org/t/elm-and-http-beginner/8507/3 "2022-07-15T09:58:52Z")

</div>

Hi @mjt  
Welcome to the community! I think [simonh100/elm-jwt](https://package.elm-lang.org/packages/simonh1000/elm-jwt/latest/) is a good fit for your investigations. Have a look at **Examples** section.

> [@klaftertief](#):
>
> [GitHub - rtfeldman/elm-spa-example: A Single Page Application written in Elm](https://github.com/rtfeldman/elm-spa-example) is a good resource for a lot or real word functionality in Elm apps.

The project uses [Http 1.0.0](https://github.com/rtfeldman/elm-spa-example/blob/master/elm.json#L13) and [it’s not updated since 2019](https://github.com/rtfeldman/elm-spa-example/commits/master).

---

<div class="post-metadata">

**Author:** ![mjt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mjt/32/4090_2.png) [@mjt](https://discourse.elm-lang.org/u/mjt)\
**Post date:** [July 15, 2022, 10:24am UTC](https://discourse.elm-lang.org/t/elm-and-http-beginner/8507/4 "2022-07-15T10:24:29Z")

</div>

Thanks klaftertief - it is a very useful example. I built it and reviewed the code you pointed out and will digest more as I spread further down that particular road.

I am hoping for a more focussed example which uses elm/http **2.0.0** rather than 1.0.0 and particularly, the **Http.post** function, in a JWT auth exchange and API query. This would be a neat example for a proposal at work that I have in mind, focussed on a username/password login to obtain a JWT auth token, then carrying that token into an API query.

The Http.post function would help to keep the example concise and show off Elm’s strong point more effectively. The less code I have to explain in the presentation, the better!

Cheers

Mike

---

<div class="post-metadata">

**Author:** ![mjt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mjt/32/4090_2.png) [@mjt](https://discourse.elm-lang.org/u/mjt)\
**Post date:** [July 15, 2022, 10:27am UTC](https://discourse.elm-lang.org/t/elm-and-http-beginner/8507/5 "2022-07-15T10:27:30Z")

</div>

Thanks novid - checking it out now!

---

<div class="post-metadata">

**Author:** ![mjt](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mjt/32/4090_2.png) [@mjt](https://discourse.elm-lang.org/u/mjt)\
**Post date:** [July 15, 2022, 10:36am UTC](https://discourse.elm-lang.org/t/elm-and-http-beginner/8507/6 "2022-07-15T10:36:35Z")

</div>

Great find thanks novid - I also like the decoder examples.

---

<div class="post-metadata">

**Author:** ![klaftertief](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/klaftertief/32/5338_2.png) [@klaftertief](https://discourse.elm-lang.org/u/klaftertief)\
**Post date:** [July 15, 2022, 12:37pm UTC](https://discourse.elm-lang.org/t/elm-and-http-beginner/8507/7 "2022-07-15T12:37:49Z")

</div>

> [@novid](#):
>
> The project uses [Http 1.0.0](https://github.com/rtfeldman/elm-spa-example/blob/master/elm.json#L13) and [it’s not updated since 2019](https://github.com/rtfeldman/elm-spa-example/commits/master).

Thanks for pointing this out. My bad for not checking. I just remembered it was updated for Elm 0.19.1 and assumed it included a port to elm/http 2.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [July 25, 2022, 12:38pm UTC](https://discourse.elm-lang.org/t/elm-and-http-beginner/8507/8 "2022-07-25T12:38:00Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
