title: how to save json object from third party api
body: <p>I'm having trouble figuring out how to save a json object from a third party api to my personal localhost mongodb. I believe I'm supposed to create another method within the api controller but am not sure what kind of method should be used any help would be great thanks!
  Here is my code sorry if this is a dumb question.</p>
  
  <pre><code>//server.js
  var express = require('express');
  var bodyParser = require('body-parser');
  var path = require('path');
  var mongoose = require('mongoose');
  var Router = require('./routes');
  var morgan = require('morgan');
  var port = process.env.PORT || 3000;
  
  var app = express();
  
  //database connect
  mongoose.connect('mongodb://localhost/Emagispace')
  
  
  app.use(
  express.static('views'),
  bodyParser.json(),
  bodyParser.urlencoded({extended : true}),
  morgan('dev')
  );
  
  Router(app);
  
  
  app.listen(port, ()=&gt;{
  console.log(`Server running on ${port}`);
  
  //Routes
  
  var API = require('./controllers/api');
  
  module.exports = (app)=&gt;{
  
  app.get('/', (req, res)=&gt;{
      res.sendFile('index.html', {root : './views'});
  });
  
  app.get('/api/emagispace', API.product)
  }
  
  //API controller
  
  var request = require('request-promise');
  var baseURI = 'example';
  
  module.exports = {
  
  product : (req, res)=&gt;{
      request({
          method : 'GET',
          url : `${baseURI}/api/emagispace/${req.query.products}`
      })
      .then((resp)=&gt;{
          console.log('Product list : ', resp);
          res.send(resp).save();
      })
  }
  }
  </code></pre>