diff --git a/02 HTTP.md b/02 HTTP.md index dffab051..857f876b 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 43-47. 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 old mode 100644 new mode 100755 index 393d04d3..bb117e94 --- a/exercises/02_http/01_url/index.js +++ b/exercises/02_http/01_url/index.js @@ -1,7 +1,5 @@ #!/usr/bin/env node -'use strict' - /* IMPORTING MODULES */ const Koa = require('koa') const Router = require('koa-router') @@ -25,9 +23,11 @@ function hello(ctx) { } router.get('/', hello) +//base case router.get('/anon', ctx => { ctx.body = 'Hello World' + //anon case }) router.get('/books/:index', ctx => { @@ -43,6 +43,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}` })