Skip to content

Commit

Permalink
Refactors server.js to maintain route to /data/index.html while still…
Browse files Browse the repository at this point in the history
… serving up idv. DB documents at /data/id=* route
  • Loading branch information
William committed Nov 18, 2015
1 parent 833187e commit 51924d3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion public/components/feedback-survey.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion public/student/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
</script>

Expand Down
6 changes: 3 additions & 3 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 51924d3

Please sign in to comment.