aboutsummaryrefslogtreecommitdiff
path: root/src/server/routes
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/routes')
-rw-r--r--src/server/routes/getSchedule.js18
-rw-r--r--src/server/routes/index.js7
2 files changed, 11 insertions, 14 deletions
diff --git a/src/server/routes/getSchedule.js b/src/server/routes/getSchedule.js
index 1734cd8..b98e76a 100644
--- a/src/server/routes/getSchedule.js
+++ b/src/server/routes/getSchedule.js
@@ -1,11 +1,10 @@
const express = require('express');
const router = express.Router();
-const request = require('request');
-const iconv = require('iconv-lite');
const getScheduleData = require('../lib/schools/hetmml/getScheduleData');
const getURLOfUser = require('../lib/schools/hetmml/getURLOfUser');
+const axios = require('../lib/schools/hetmml/axios');
// copied from http://www.meetingpointmco.nl/Roosters-AL/doc/dagroosters/untisscripts.js,
// were using the same code as they do to be sure that we always get the same
@@ -45,16 +44,13 @@ router.get('/:type/:value', (req, res, next) => {
const url = getURLOfUser(scheduleType, type, index, week);
- request(url, { encoding: null }, (err, data) => {
- if (err) {
+ axios.get(url)
+ .then((response) => {
+ res.status(response.status).end(response.data);
+ })
+ .catch((err) => {
next(err);
- return;
- }
-
- const utf8Body = iconv.decode(data.body, 'ISO-8859-1');
-
- res.status(data.statusCode).end(utf8Body);
- });
+ });
});
});
diff --git a/src/server/routes/index.js b/src/server/routes/index.js
index af82e1f..78f31f3 100644
--- a/src/server/routes/index.js
+++ b/src/server/routes/index.js
@@ -27,10 +27,11 @@ router.get(['/', '/s/*', '/t/*', '/r/*', '/c/*'], (req, res) => {
dailyScheduleWeeksStr,
basisScheduleWeeksStr,
});
- }).catch(() => {
- console.error('Unable to get user info, emergency redirect!');
- res.render('redirect');
});
+ // .catch(() => {
+ // console.error('Unable to get user info, emergency redirect!');
+ // res.render('redirect');
+ // });
});
module.exports = router;