diff --git a/02 HTTP.md b/02 HTTP.md index dffab051..80943f2b 100644 --- a/02 HTTP.md +++ b/02 HTTP.md @@ -149,7 +149,7 @@ Whilst URL parameters are used to define unique URLS to identify online resource 2. Now change the URL to `/hello/John%20Doe?format=upper`. 1. Notice that the same data has been displayed just the format has changed. -Open the `index.js` file. The route is between lines 37-43. +Open the `index.js` file. The route is between lines 48-52. 1. Notice that the query string(s) are not part of the route. 2. The query string comprises name-value pairs. diff --git a/exercises/02_http/01_url/index.js b/exercises/02_http/01_url/index.js index ed2133d6..c7a9340a 100644 --- a/exercises/02_http/01_url/index.js +++ b/exercises/02_http/01_url/index.js @@ -30,9 +30,11 @@ function hello(ctx) { } router.get('/', hello) +// base case router.get('/anon', ctx => { ctx.body = 'Hello World' + // anon case }) router.get('/books/:index', ctx => { @@ -48,6 +50,7 @@ router.get('/name', ctx => ctx.body = JSON.stringify(ctx.query)) router.get('/hello/:name', ctx => { let myname = ctx.params.name if(ctx.query.format === 'upper') myname = myname.toUpperCase() + // only applies uppercase if formatting query exists ctx.body = `hello ${myname}` })