title: Express - get router.get to return json data attribute
body: <p>I am new to javascript and would like to retrieve the json response from my express route get request. I can return the whole json but when i try to return a specific element i recieve an error (eg <strong>res.body.data).</strong> Here is my route file </p>
  
  <p>route.js</p>
  
  <pre><code>var express = require('express');
  var router = express.Router();
  var request = require('request');
  router.get('/', function(req, res, next) {
    request({
      uri: 'https://www.reddit.com/r/meme/new/.json'
    }).pipe(res);
  });
  module.exports = router;
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>var createError = require('http-errors');
  var express = require('express');
  var path = require('path');
  var cookieParser = require('cookie-parser');
  var logger = require('morgan');
  var cors = require("cors");
  var indexRouter = require('./routes/index');
  var usersRouter = require('./routes/users');
  var testAPIRouter = require('./routes/testAPI');
  var route = require('./routes/route');
  
  var app = express();
  // view engine setup
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'jade');
  app.use(cors());
  app.use(logger('dev'));
  app.use(express.json());
  
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, 'public')));
  
  app.use('/', indexRouter);
  app.use('/users', usersRouter);
  app.use('/testAPI', testAPIRouter);
  app.use('/route', route);
  // catch 404 and forward to error handler
  app.use(function(req, res, next) {
    next(createError(404));
  });
  
  // error handler
  app.use(function(err, req, res, next) {
    // set locals, only providing error in development
    res.locals.message = err.message;
    res.locals.error = req.app.get('env') === 'development' ? err : {};
  
    // render the error page
    res.status(err.status || 500);
    res.render('error');
  });
  module.exports = app;
  </code></pre>