aboutsummaryrefslogtreecommitdiff
path: root/routes
diff options
context:
space:
mode:
authorNoah Loomans <noahloomans@gmail.com>2016-12-15 14:13:43 +0100
committerNoah Loomans <noahloomans@gmail.com>2016-12-15 14:13:43 +0100
commitb6542a78c14b3d2e350b6620272a88094abda1c1 (patch)
treeb4e33cdb51970ea0dbc6068cc33b28aaa0c3172d /routes
parent13ceee415eb81a4d72f63df013eca2a442865d81 (diff)
add user frendly error handling
Diffstat (limited to 'routes')
-rw-r--r--routes/meetingpointProxy.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/routes/meetingpointProxy.js b/routes/meetingpointProxy.js
index cec74a8..b2b51c9 100644
--- a/routes/meetingpointProxy.js
+++ b/routes/meetingpointProxy.js
@@ -1,16 +1,17 @@
var express = require('express')
var router = express.Router()
-const Promise = require('bluebird')
-const request = Promise.promisify(require('request'))
-const encoding = require('encoding')
+const request = require('request')
/* GET home page. */
router.get('/:url', function (req, res, next) {
- request(`http://www.meetingpointmco.nl/${req.params.url}`)
- .then(raw => raw.body)
- .then(page => encoding.convert(page, 'UTF-8', 'Windows-1252'))
- .then(body => { res.end(body) })
- .catch(next)
+ const url = `http://www.meetingpointmco.nl/${req.params.url}`
+ request(url, function (err, data) {
+ if (err) {
+ next(err)
+ return
+ }
+ res.status(data.statusCode).end(data.body)
+ })
})
module.exports = router