From a3079666b4d9aabd1db9a72322152fec256eda36 Mon Sep 17 00:00:00 2001 From: deck Date: Sun, 1 Jun 2014 22:45:29 +0300 Subject: [PATCH 01/12] new branch --- SPA/index.html | 10 ++++------ SPA/pages/about.html | 19 ++++++------------- SPA/pages/home.html | 18 +++++++++++++++--- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/SPA/index.html b/SPA/index.html index 81e6f29..4da9b22 100644 --- a/SPA/index.html +++ b/SPA/index.html @@ -22,13 +22,13 @@ - + +
  • Contact
  • - + -->
    @@ -40,9 +40,7 @@
    diff --git a/SPA/pages/about.html b/SPA/pages/about.html index fe27d10..98cdfe2 100644 --- a/SPA/pages/about.html +++ b/SPA/pages/about.html @@ -1,15 +1,8 @@
    - {{message.name}}
    - Best Italian Sellers
    - {{message.best.name}}
    - {{message.best.ingredients}}
    - {{message.best.price}}
    - Pizza
    - {{message.pizza.name}}
    - {{message.pizza.ingredients}}
    - {{message.pizza.price}}
    - Pasta
    - {{message.pasta.name}}
    - {{message.pasta.ingredients}}
    - {{message.pasta.price}} + {{ message.name }} +
  • +

    {{ message.name }}

    + {{ message.address }},{{ message.city }}
    + {{ message.phone }} +
  • \ No newline at end of file diff --git a/SPA/pages/home.html b/SPA/pages/home.html index 9647219..08eadfe 100644 --- a/SPA/pages/home.html +++ b/SPA/pages/home.html @@ -1,4 +1,16 @@ -
    - Home -
  • {{ message.name }}
    {{ message.address }},{{ message.city }}
    {{ message.phone }}
  • +
    + About
    + {{message.name}}
    + Best Italian Sellers
    + {{message.best.name}}
    + {{message.best.ingredients}}
    + {{message.best.price}}
    + Pizza
    + {{message.pizza.name}}
    + {{message.pizza.ingredients}}
    + {{message.pizza.price}}
    + Pasta
    + {{message.pasta.name}}
    + {{message.pasta.ingredients}}
    + {{message.pasta.price}}
    \ No newline at end of file From fd7650ecd41a27f785a1690301d5c525c49f43ef Mon Sep 17 00:00:00 2001 From: deck Date: Sun, 1 Jun 2014 23:41:12 +0300 Subject: [PATCH 02/12] naked --- SPA/index.html | 33 ++++++++------------------------- SPA/pages/about.html | 12 +++++++++--- SPA/pages/home.html | 31 +++++++++++++++++++------------ 3 files changed, 36 insertions(+), 40 deletions(-) diff --git a/SPA/index.html b/SPA/index.html index 4da9b22..8e09763 100644 --- a/SPA/index.html +++ b/SPA/index.html @@ -1,12 +1,15 @@ - - + - - + @@ -17,31 +20,11 @@ - - -
    -
    - -
    -
    - -
    +
    diff --git a/SPA/pages/about.html b/SPA/pages/about.html index 98cdfe2..7d89555 100644 --- a/SPA/pages/about.html +++ b/SPA/pages/about.html @@ -1,8 +1,14 @@ -
    +
    +

    {{message.name}}

    +
    + +
    + +
    {{ message.name }} -
  • {{ message.name }}

    {{ message.address }},{{ message.city }}
    {{ message.phone }} -
  • \ No newline at end of file diff --git a/SPA/pages/home.html b/SPA/pages/home.html index 08eadfe..03176a7 100644 --- a/SPA/pages/home.html +++ b/SPA/pages/home.html @@ -1,16 +1,23 @@ -
    - About
    - {{message.name}}
    - Best Italian Sellers
    - {{message.best.name}}
    - {{message.best.ingredients}}
    +
    +
    +

    {{message.name}}

    +
    + +
    + + +

    Best Italian Sellers

    +

    {{message.best.name}}

    +

    {{message.best.ingredients}}

    {{message.best.price}}
    - Pizza
    - {{message.pizza.name}}
    - {{message.pizza.ingredients}}
    +

    Pizza

    +

    {{message.pizza.name}}

    +

    {{message.pizza.ingredients}}

    {{message.pizza.price}}
    - Pasta
    - {{message.pasta.name}}
    - {{message.pasta.ingredients}}
    +

    Pasta

    +

    {{message.pasta.name}}

    +

    {{message.pasta.ingredients}}

    {{message.pasta.price}}
    \ No newline at end of file From 004c7c297faab881d598be2e4e43d2df03026ca5 Mon Sep 17 00:00:00 2001 From: deck Date: Mon, 2 Jun 2014 00:02:26 +0300 Subject: [PATCH 03/12] front end --- SPA/index.html | 10 +++++++--- SPA/pages/.contact.html | 7 +++++++ SPA/pages/about.html | 12 ++++++------ SPA/pages/home.html | 25 ++++++++++++++----------- SPA/script.js | 10 +++++----- restaurant.json | 2 +- 6 files changed, 40 insertions(+), 26 deletions(-) create mode 100644 SPA/pages/.contact.html diff --git a/SPA/index.html b/SPA/index.html index 8e09763..65c7df6 100644 --- a/SPA/index.html +++ b/SPA/index.html @@ -3,13 +3,17 @@ - + + diff --git a/SPA/pages/.contact.html b/SPA/pages/.contact.html new file mode 100644 index 0000000..7efeafa --- /dev/null +++ b/SPA/pages/.contact.html @@ -0,0 +1,7 @@ +
    + contact +

    {{ message.name }}

    + +

    {{ message.address }}

    +

    {{ message.city }}

    +
    \ No newline at end of file diff --git a/SPA/pages/about.html b/SPA/pages/about.html index 7d89555..3511ec5 100644 --- a/SPA/pages/about.html +++ b/SPA/pages/about.html @@ -1,14 +1,14 @@

    {{message.name}}

    - + + + Back + +
    - {{ message.name }} -

    {{ message.name }}

    {{ message.address }},{{ message.city }}
    - {{ message.phone }} + {{ message.phone }}
    \ No newline at end of file diff --git a/SPA/pages/home.html b/SPA/pages/home.html index 03176a7..a327f6c 100644 --- a/SPA/pages/home.html +++ b/SPA/pages/home.html @@ -2,22 +2,25 @@

    {{message.name}}

    - -
    - + + About + +
    + +

    Best Italian Sellers

    {{message.best.name}}

    -

    {{message.best.ingredients}}

    - {{message.best.price}}
    + Ingredients: {{message.best.ingredients}} + Price: {{message.best.price}}
    +

    Pizza

    {{message.pizza.name}}

    -

    {{message.pizza.ingredients}}

    - {{message.pizza.price}}
    + Ingredients: {{message.pizza.ingredients}} + Price: {{message.pizza.price}}
    +

    Pasta

    {{message.pasta.name}}

    -

    {{message.pasta.ingredients}}

    - {{message.pasta.price}} + Ingredients: {{message.pasta.ingredients}} + Price: {{message.pasta.price}}
    \ No newline at end of file diff --git a/SPA/script.js b/SPA/script.js index ae1f72e..0b5ed4c 100644 --- a/SPA/script.js +++ b/SPA/script.js @@ -18,10 +18,10 @@ }) // route for the contact page - .when('/contact', { +/* .when('/contact', { templateUrl : 'SPA/pages/contact.html', controller : 'contactController' - }); + });*/ }); // create the controller and inject Angular's $scope @@ -39,7 +39,7 @@ }); scotchApp.controller('aboutController', function($scope,$http,$routeParams) { - $http({method: 'GET', url: 'http://localhost:3412/rest/'+$routeParams.restId}). + $http({method: 'GET', url: 'http://localhost:3412/rest/'+ $routeParams.restId}). success(function(data, status, headers, config) { $scope.message = data; @@ -50,7 +50,7 @@ }); }); - scotchApp.controller('contactController', function($scope,$http) { +/* scotchApp.controller('contactController', function($scope,$http) { $http({method: 'GET', url: 'http://localhost:3412/rest/1'}). success(function(data, status, headers, config) { @@ -60,4 +60,4 @@ error(function(data, status, headers, config) { }); - }); \ No newline at end of file + });*/ \ No newline at end of file diff --git a/restaurant.json b/restaurant.json index b27cf59..77b2f08 100644 --- a/restaurant.json +++ b/restaurant.json @@ -4,7 +4,7 @@ "name": "First Pizza Pronto Restaurant", "address": "71A Aripita Avenue Woodbrook", "city": "Port of spain", - "phone": "+40 743 105 932", + "phone": "+xx xxx xxx xxx", "best": { "name":"pizza 1", "ingredients":"one, two, three", From 6ae5cca7aa9c12337836455e4b45dc88ab60fd49 Mon Sep 17 00:00:00 2001 From: deck Date: Mon, 2 Jun 2014 00:04:55 +0300 Subject: [PATCH 04/12] back end --- app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app.js b/app.js index ec5f38e..12dc12f 100644 --- a/app.js +++ b/app.js @@ -20,7 +20,6 @@ app.use(express.bodyParser()); app.get('/', function(req,res) { res.sendfile('SPA/index.html'); - //res.json(obj); }); app.get('/rest', function(req, res) { From 1f48e16c86ab3070278eddfc017f8218f972fa3b Mon Sep 17 00:00:00 2001 From: deck Date: Mon, 2 Jun 2014 00:39:16 +0300 Subject: [PATCH 05/12] nesting --- SPA/pages/home.html | 30 +++++++++++++++---------- restaurant.json | 55 +++++++++++++++++++++++++++------------------ 2 files changed, 51 insertions(+), 34 deletions(-) diff --git a/SPA/pages/home.html b/SPA/pages/home.html index a327f6c..38f38f0 100644 --- a/SPA/pages/home.html +++ b/SPA/pages/home.html @@ -9,18 +9,24 @@

    {{message.name}}


    -

    Best Italian Sellers

    -

    {{message.best.name}}

    - Ingredients: {{message.best.ingredients}} - Price: {{message.best.price}}
    +

    Best Italian Sellers

    +
    +

    {{value.name}}

    + Ingredients: {{value.ingredients}} + Price: {{value.price}} +
    -

    Pizza

    -

    {{message.pizza.name}}

    - Ingredients: {{message.pizza.ingredients}} - Price: {{message.pizza.price}}
    +
    +

    Pizza

    +

    {{value.name}}

    + Ingredients: {{value.ingredients}} + Price: {{value.price}} +
    -

    Pasta

    -

    {{message.pasta.name}}

    - Ingredients: {{message.pasta.ingredients}} - Price: {{message.pasta.price}} +
    +

    Pasta

    +

    {{value.name}}

    + Ingredients: {{value.ingredients}} + Price: {{value.price}} +
    \ No newline at end of file diff --git a/restaurant.json b/restaurant.json index 77b2f08..30dce3b 100644 --- a/restaurant.json +++ b/restaurant.json @@ -1,24 +1,35 @@ [ - { - "id": 0, - "name": "First Pizza Pronto Restaurant", - "address": "71A Aripita Avenue Woodbrook", - "city": "Port of spain", - "phone": "+xx xxx xxx xxx", - "best": { - "name":"pizza 1", - "ingredients":"one, two, three", - "price":"9.00 USD" - }, - "pizza": { - "name":"Pizza Prosciuto", - "ingredients":"one one one", - "price":"10.00 USD" - }, - "pasta": { - "name": "Spaghetti All Arabiatello", - "ingredients": "pasta faina", - "price": "8.00 USD" - } - } + { + "id": 0, + "name": "First Pizza Pronto Restaurant", + "address": "71A Aripita Avenue Woodbrook", + "city": "Port of spain", + "phone": "+xx xxx xxx xxx", + "best": [ + { + "name": "Pizza Margherita", + "ingredients": "tomato sauce, mozzarella", + "price": "9.00 USD" + }, + { + "name": "Penne Alla Siciliana", + "ingredients": "pasta with aubergines, mozzarella and tomato sauce", + "price": "8.00 USD" + } + ], + "pizza": [ + { + "name": "Pizza Prosciuto", + "ingredients": "one one one", + "price": "10.00 USD" + } + ], + "pasta": [ + { + "name": "Spaghetti All Arabiatello", + "ingredients": "pasta faina", + "price": "8.00 USD" + } + ] + } ] \ No newline at end of file From 7407786bc02ecde57c7162a9c6975e14f190e319 Mon Sep 17 00:00:00 2001 From: deck Date: Mon, 2 Jun 2014 01:40:03 +0300 Subject: [PATCH 06/12] styling --- SPA/index.html | 27 ++++++++++++++++++--------- SPA/pages/about.html | 9 +++------ SPA/pages/home.html | 9 +++------ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/SPA/index.html b/SPA/index.html index 65c7df6..cd848d8 100644 --- a/SPA/index.html +++ b/SPA/index.html @@ -1,24 +1,33 @@ - + + diff --git a/SPA/pages/about.html b/SPA/pages/about.html index 3511ec5..72c6edc 100644 --- a/SPA/pages/about.html +++ b/SPA/pages/about.html @@ -1,11 +1,8 @@ -
    -

    {{message.name}}

    +
    +

    {{message.name}}

    + Back
    - - Back - -
    diff --git a/SPA/pages/home.html b/SPA/pages/home.html index 38f38f0..1730021 100644 --- a/SPA/pages/home.html +++ b/SPA/pages/home.html @@ -1,12 +1,9 @@
    -
    -

    {{message.name}}

    +
    +

    {{message.name}}

    + About
    - - About - -

    Best Italian Sellers

    From a76d01f914d57ad7b8088635308475c6a0272072 Mon Sep 17 00:00:00 2001 From: deck Date: Mon, 2 Jun 2014 02:19:00 +0300 Subject: [PATCH 07/12] commit --- SPA/index.html | 4 +++- SPA/pages/home.html | 33 +++++++++++++++++++++------------ restaurant.json | 7 ++++++- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/SPA/index.html b/SPA/index.html index cd848d8..10a1848 100644 --- a/SPA/index.html +++ b/SPA/index.html @@ -3,7 +3,6 @@ - @@ -18,6 +17,9 @@ h2.left{ display:inline; } + h2.dash{ + border-bottom: 1px dashed rgba(0,0,0,0.1); + } a.right { float:right; } diff --git a/SPA/pages/home.html b/SPA/pages/home.html index 1730021..01c0a91 100644 --- a/SPA/pages/home.html +++ b/SPA/pages/home.html @@ -6,24 +6,33 @@

    {{message.name}}

    -

    Best Italian Sellers

    +

    Best Italian Sellers

    -

    {{value.name}}

    - Ingredients: {{value.ingredients}} - Price: {{value.price}} +
    +

    {{value.name}}

    +

    Ingredients: {{value.ingredients}}
    + Price: {{value.price}}

    +
    +
    +

    Pizza

    -

    Pizza

    -

    {{value.name}}

    - Ingredients: {{value.ingredients}} - Price: {{value.price}} +
    +

    {{value.name}}

    +

    Ingredients: {{value.ingredients}}
    + Price: {{value.price}}

    +
    +
    +

    Pasta

    -

    Pasta

    -

    {{value.name}}

    - Ingredients: {{value.ingredients}} - Price: {{value.price}} +
    +

    {{value.name}}

    +

    Ingredients: {{value.ingredients}}
    + Price: {{value.price}}

    +
    +
    \ No newline at end of file diff --git a/restaurant.json b/restaurant.json index 30dce3b..a664b3a 100644 --- a/restaurant.json +++ b/restaurant.json @@ -1,7 +1,7 @@ [ { "id": 0, - "name": "First Pizza Pronto Restaurant", + "name": "Pizza Pronto Restaurant", "address": "71A Aripita Avenue Woodbrook", "city": "Port of spain", "phone": "+xx xxx xxx xxx", @@ -22,6 +22,11 @@ "name": "Pizza Prosciuto", "ingredients": "one one one", "price": "10.00 USD" + }, + { + "name":"Pizza Margherita", + "ingredients":"sos, mozzarella, rosii, busuioc", + "price": "less" } ], "pasta": [ From ff751fb5d02f020a56fc7fb803b212f4f0611d55 Mon Sep 17 00:00:00 2001 From: deck Date: Mon, 2 Jun 2014 12:10:25 +0300 Subject: [PATCH 08/12] address --- SPA/pages/about.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/SPA/pages/about.html b/SPA/pages/about.html index 72c6edc..b48c23f 100644 --- a/SPA/pages/about.html +++ b/SPA/pages/about.html @@ -5,7 +5,8 @@

    {{message.name}}

    -
    - {{ message.address }},{{ message.city }}
    - {{ message.phone }} -
    \ No newline at end of file +
    + {{message.name}} Intl.
    + {{ message.address }},{{ message.city }}
    + {{ message.phone }} +
    From 2e2f8b0d303867235219bddb318ce399a4979afe Mon Sep 17 00:00:00 2001 From: deck Date: Tue, 3 Jun 2014 12:11:24 +0300 Subject: [PATCH 09/12] set redis as main database --- app.js | 81 ++++++++++++++++++++-------------------------------- package.json | 3 +- 2 files changed, 33 insertions(+), 51 deletions(-) diff --git a/app.js b/app.js index 12dc12f..7135b93 100644 --- a/app.js +++ b/app.js @@ -1,19 +1,20 @@ var express = require('express'); var app = express(); - -// Declare variables -var fs = require('fs'), - obj - -// Read the file and send to the callback -fs.readFile(__dirname + '/restaurant.json', handleFile) - -// Write the callback function -function handleFile(err, data) { - if (err) throw err - obj = JSON.parse(data) - // You can now play with your datas -} +// Introducing Redis +var _redis = require("redis"), +redis = _redis.createClient(); + +var restaurants = '[{"id":0,"name":"Pizza Pronto Restaurant","address":"71A Aripita Avenue Woodbrook","city":"Port of spain","phone":"+xx xxx xxx xxx","best":[{"name":"Pizza Margherita","ingredients":"tomato sauce, mozzarella","price":"9.00 USD"},{"name":"Penne Alla Siciliana","ingredients":"pasta with aubergines, mozzarella and tomato sauce","price":"8.00 USD"}],"pizza":[{"name":"Pizza Prosciuto","ingredients":"one one one","price":"10.00 USD"},{"name":"Pizza Margherita","ingredients":"sos, mozzarella, rosii, busuioc","price":"less"}],"pasta":[{"name":"Spaghetti All Arabiatello","ingredients":"pasta faina","price":"8.00 USD"}]}]'; + +redis.select(1, function(err,res){ + // you'll want to check that the select was successful here + if(err) return err; + else { + redis.setnx('nodejs', restaurants, function(error, result) { + if (error) res.send('Error: ' + error); + else console.log("saved"); + });} +}); app.use("/SPA", express.static(__dirname + '/SPA')); app.use(express.bodyParser()); @@ -23,48 +24,28 @@ app.get('/', function(req,res) { }); app.get('/rest', function(req, res) { - res.json(obj); -}); - -app.get('/rest/random', function(req, res) { - var id = Math.floor(Math.random() * obj.length); - var q = obj[id]; - res.json(q); + redis.get('nodejs', function(error, result) { + if (error) res.send('Error: '+ error); + else { + json = JSON.parse(result); + res.json(json); + } + }); }); app.get('/rest/:id', function(req, res) { - if(obj.length <= req.params.id || req.params.id < 0) { + redis.get('nodejs', function(error, result) { + if (error) res.send('Error: '+ error); + else { + if(result.length <= req.params.id || req.params.id < 0) { res.statusCode = 404; return res.send('Error 404: No quote found'); } - - var q = obj[req.params.id]; - res.json(q); -}); -/* -app.post('/rest', function(req, res) { - if(!req.body.hasOwnProperty('author') || !req.body.hasOwnProperty('text')) { - res.statusCode = 400; - return res.send('Error 400: Post syntax incorrect.'); - } - - var newQuote = { - author : req.body.author, - text : req.body.text - }; - - quotes.push(newQuote); - res.json(true); + json = JSON.parse(result); + var q = json[req.params.id]; + res.json(q); + } + }); }); -app.delete('/quote/:id', function(req, res) { - if(quotes.length <= req.params.id) { - res.statusCode = 404; - return res.send('Error 404: No quote found'); - } - - quotes.splice(req.params.id, 1); - res.json(true); -});*/ - app.listen(process.env.PORT || 3412); \ No newline at end of file diff --git a/package.json b/package.json index e64af87..1d06f6e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "private" : true, "version": "0.0.1", "dependencies": { - "express": "3.x" + "express": "3.x", + "redis": "0.8.x" }, "main" : "app" } \ No newline at end of file From 228b8dd55f8f76420cb773a7da1cbfdd9d912479 Mon Sep 17 00:00:00 2001 From: deck Date: Tue, 3 Jun 2014 22:16:26 +0300 Subject: [PATCH 10/12] read result --- app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app.js b/app.js index 7135b93..8255e77 100644 --- a/app.js +++ b/app.js @@ -12,7 +12,8 @@ redis.select(1, function(err,res){ else { redis.setnx('nodejs', restaurants, function(error, result) { if (error) res.send('Error: ' + error); - else console.log("saved"); + else if (result === 0) console.log('the key already exist'); + else console.log('saved'); });} }); From a2204caa3afc0aa2a7930105af082eadf34938e8 Mon Sep 17 00:00:00 2001 From: deck Date: Tue, 3 Jun 2014 22:33:06 +0300 Subject: [PATCH 11/12] dash --- SPA/index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SPA/index.html b/SPA/index.html index 10a1848..a1abf81 100644 --- a/SPA/index.html +++ b/SPA/index.html @@ -29,6 +29,9 @@ border-bottom:1px dashed rgba(0,0,0,0.3); margin-bottom: 5px; } + blockquote{ + border-bottom: 1px dashed rgba(0,0,0,0.1); + } From 0fc2e6316cf998f5a1fc5084c2a7ef50dca316a5 Mon Sep 17 00:00:00 2001 From: deck Date: Sun, 15 Jun 2014 09:54:41 +0300 Subject: [PATCH 12/12] hm --- app.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index 8255e77..ee342ac 100644 --- a/app.js +++ b/app.js @@ -4,7 +4,7 @@ var app = express(); var _redis = require("redis"), redis = _redis.createClient(); -var restaurants = '[{"id":0,"name":"Pizza Pronto Restaurant","address":"71A Aripita Avenue Woodbrook","city":"Port of spain","phone":"+xx xxx xxx xxx","best":[{"name":"Pizza Margherita","ingredients":"tomato sauce, mozzarella","price":"9.00 USD"},{"name":"Penne Alla Siciliana","ingredients":"pasta with aubergines, mozzarella and tomato sauce","price":"8.00 USD"}],"pizza":[{"name":"Pizza Prosciuto","ingredients":"one one one","price":"10.00 USD"},{"name":"Pizza Margherita","ingredients":"sos, mozzarella, rosii, busuioc","price":"less"}],"pasta":[{"name":"Spaghetti All Arabiatello","ingredients":"pasta faina","price":"8.00 USD"}]}]'; +var restaurants = '[{"id":0,"name":"Pizza Pronto Restaurant","address":"71A Aripita Avenue Woodbrook","city":"Port of spain","phone":"1","best":[{"name":"Pizza Margherita","ingredients":"tomato sauce, mozzarella","price":"9.00 USD"},{"name":"Penne Alla Siciliana","ingredients":"pasta with aubergines, mozzarella and tomato sauce","price":"8.00 USD"}],"pizza":[{"name":"Pizza Prosciuto","ingredients":"one one one","price":"10.00 USD"},{"name":"Pizza Margherita","ingredients":"sos, mozzarella, rosii, busuioc","price":"less"}],"pasta":[{"name":"Spaghetti All Arabiatello","ingredients":"pasta faina","price":"8.00 USD"}]}]'; redis.select(1, function(err,res){ // you'll want to check that the select was successful here @@ -34,16 +34,12 @@ app.get('/rest', function(req, res) { }); }); -app.get('/rest/:id', function(req, res) { +app.get('/rest/:no', function(req, res) { redis.get('nodejs', function(error, result) { if (error) res.send('Error: '+ error); else { - if(result.length <= req.params.id || req.params.id < 0) { - res.statusCode = 404; - return res.send('Error 404: No quote found'); - } json = JSON.parse(result); - var q = json[req.params.id]; + var q = json[req.params.no]; res.json(q); } });