Skip to content
Permalink
Browse files
fixed pull request
  • Loading branch information
aa7401 committed Sep 15, 2019
1 parent 49921f1 commit c197be6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
@@ -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.
@@ -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}`
})

0 comments on commit c197be6

Please sign in to comment.