Elm and Http beginner

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

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,


1 Like

GitHub - rtfeldman/elm-spa-example: A Single Page Application written in Elm 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

Hi @mjt
Welcome to the community! I think simonh100/elm-jwt is a good fit for your investigations. Have a look at Examples section.

The project uses Http 1.0.0 and it’s not updated since 2019.

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!



Thanks novid - checking it out now!

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

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.

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