O'Reilly logo

Programming Elm by Jeremy Fairbank

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handle Dynamic Routes

Up to this point, you’ve used static URL paths such as / and /account that fetch static resources. Many SPAs also access dynamic resources through parameterized paths. For example, a path of /photo/42 would fetch and display the photo with an ID of 42.

In this section, you will learn how to handle dynamic paths. You will add the ability to view an individual user’s feed of photos. You will create a parameterized route for a user’s feed. Then, you will make wrapper components that reuse the Feed component to display the public feed and user feeds.

You will use usernames to fetch user feeds, so start by displaying the username associated with a photo. Open Feed.elm in your editor. Add a String username field below the comments ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required