How to get request parameters in Elm?

In my Elm program, I would like to initialize my model based on the query string.

For example, if the query string is ?w=3&h=5 , I would like:

 initialModel = { width = 3 , height = 5 } 

Is it possible to achieve this in Elm, or the only way to do this is to get the request parameters in Javascript and pass them through the port?

+8
elm
source share
1 answer

There is no built-in base library method for accessing a URL. You can use the ports and community library jessitron / elm-param-parsing .

If you also want to set the URL, you can use the ports again, or you can use the history API, for which there are bindings in TheSeamau5 / elm-history .

+7
source share

All Articles