From 5f02d1e9487c68155ef5723ef3662236a9fc8138 Mon Sep 17 00:00:00 2001 From: David Jay Date: Thu, 3 Nov 2016 10:52:29 -0700 Subject: [PATCH] Simplifying mock routes and adding error handling. --- routes/api/stream/index.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/routes/api/stream/index.js b/routes/api/stream/index.js index feb3faf9d..155450d42 100644 --- a/routes/api/stream/index.js +++ b/routes/api/stream/index.js @@ -2,10 +2,9 @@ const express = require('express'); const router = express.Router(); -router.get('/', (req, res) => { - console.log('Stream endpoint has been hit with asset_id ', req.query.asset_id) - res.setHeader('Content-Type', 'application/json'); - res.send(JSON.stringify([ +router.get('/', (req, res, next) => { + console.log('Stream endpoint has been hit with asset_id ', req.query.asset_id); + res.json([ { 'id': 'abc', 'type': 'comment', @@ -28,7 +27,7 @@ router.get('/', (req, res) => { 'created_at': new Date().getTime() - 400000, 'asset_id': 'assetTest' } - ])); + ]).catch(next); }); module.exports = router;