From 149b05ef28edeb669f1397a8973eb48b7b7d0495 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Wed, 27 Sep 2017 17:55:07 +0200 Subject: [PATCH] Calling function for fetching all the requested items. --- .../controllers/plex/fetchRequested.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 seasoned_api/src/webserver/controllers/plex/fetchRequested.js diff --git a/seasoned_api/src/webserver/controllers/plex/fetchRequested.js b/seasoned_api/src/webserver/controllers/plex/fetchRequested.js new file mode 100644 index 0000000..18b92fc --- /dev/null +++ b/seasoned_api/src/webserver/controllers/plex/fetchRequested.js @@ -0,0 +1,23 @@ +const RequestRepository = require('src/plex/requestRepository.js'); +const requestRepository = new RequestRepository(); + +/** + * Controller: Retrieves search history of a logged in user + * @param {Request} req http request variable + * @param {Response} res + * @returns {Callback} + */ +function historyController(req, res) { + const user = req.loggedInUser; + console.log('here') + + requestRepository.fetchRequested() + .then((requestedItems) => { + res.send({ success: true, requestedItems }); + }) + .catch((error) => { + res.status(401).send({ success: false, error: error.message }); + }); +} + +module.exports = historyController;