From 03e4e0c6ecf7fb66b4981c9e29ed0254ccbf3997 Mon Sep 17 00:00:00 2001 From: Serge Matebook Date: Sun, 15 Sep 2019 19:31:52 +0100 Subject: [PATCH 1/2] Different lines because of bug fix --- 02 HTTP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 7f5891268beb26f5d77eae073bd452ce3df2b855 Mon Sep 17 00:00:00 2001 From: Serge Matebook Date: Sun, 15 Sep 2019 19:43:36 +0100 Subject: [PATCH 2/2] Added comments --- exercises/02_http/01_url/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) mode change 100644 => 100755 exercises/02_http/01_url/index.js 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}` })