From 51924d351b96f4539316a0e0aac65f1df84b1dd1 Mon Sep 17 00:00:00 2001 From: William Date: Tue, 17 Nov 2015 21:39:17 -0800 Subject: [PATCH] Refactors server.js to maintain route to /data/index.html while still serving up idv. DB documents at /data/id=* route --- public/components/feedback-survey.js | 2 +- public/student/index.html | 1 - server/server.js | 6 +++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/public/components/feedback-survey.js b/public/components/feedback-survey.js index 3dc2e4d..bc31f3d 100644 --- a/public/components/feedback-survey.js +++ b/public/components/feedback-survey.js @@ -108,7 +108,7 @@ var id = window.location.href.split('?'); id = id[id.length-1]; console.log('id: ' + id); - $.get('http://localhost:8000/data/' + id, function(hrObj) { + $.get('http://localhost:8000/data/id=' + id, function(hrObj) { console.log('data: ' + JSON.stringify(data)); this.setState({ data: hrObj diff --git a/public/student/index.html b/public/student/index.html index 0784b9a..dad827d 100644 --- a/public/student/index.html +++ b/public/student/index.html @@ -21,7 +21,6 @@ alert('Your Help Request was recently closed. Please fill out the feedback survey'); var redirectURL = 'http://localhost:8000/student/feedback-survey.html?' + hrObj._id; window.location.replace(redirectURL); - // serve the feedback survey }); diff --git a/server/server.js b/server/server.js index 79e70d4..7573bcb 100644 --- a/server/server.js +++ b/server/server.js @@ -132,10 +132,10 @@ app.get('/data', function(req, res, next) { }); }); // retrieve Help Request -app.get('/data/*', function(req, res, next) { +app.get('/data/id=*', function(req, res, next) { + console.log('here'); // grab unique db entry ID - var id = path.parse(req.path).base; - console.log('id: ' + id); + var id = path.parse(req.path).base.slice(3); helprequests.findById(id) .then(function(found) { if (!found) {