commit bd2eef9191880e06a2f996f4a80837e00712eae0
parent 5aee9f5693473e9b0c437e10aaa098156beba1a1
Author: Konstantin Tarkus <koistya@gmail.com>
Date: Tue, 8 Sep 2015 16:28:21 +0300
Merge pull request #245 from ademuk/patch-1
Fixed parameterized route example
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/docs/recipes/how-to-implement-routing.md b/docs/recipes/how-to-implement-routing.md
@@ -86,7 +86,7 @@ window.addEventListener('hashchange', () => render());
render();
```
-### Step 3: Parametrized Routes
+### Step 3: Parameterized Routes
**(1)** Convert the list of routes from hash table to an array, this way the
order of routes will be preserved. **(2)** Wrap this collection into a Router
@@ -109,8 +109,8 @@ const router = new Router(on => {
const data = await http.get('/api/products');
return <Layout><ProductListing {...data} /></Layout>
});
- on('/products/:id', async (id) => {
- const data = await http.get(`/api/products/${id}`);
+ on('/products/:id', async (req) => {
+ const data = await http.get(`/api/products/${req.params.id}`);
return <Layout><ProductInfo {...data} /></Layout>;
});
}]);