I'm relatively new to NodeJS. I've created an app using ExpressJS and LocomotiveJS framework. How would I save a certain GET response to a variable within a controller. For example:
file: cartController.js
var locomotive = require('locomotive');
var Controller = locomotive.Controller;
var cartController = new Controller();
var Cart = require('../models/cartsModel.js');
var cart = new Cart();
cartController.index = function(){
var getStoreDetails = function(cart, callback) {
for (var key in cart.productsByStores) {
//*****************************
//This is what I'm looking for:
//*****************************
store_details = this.get('/stores/' . key);
cart.productsByStores[key] = {'store_details' : store_details, 'products' : cart.productsByStores[key]};
}
return this.res.json(cart.productsByStores);
//console.log('store: ', store);
};
}
The response in that GET is already set up. What I'm missing is how to access and save that response to an object.
I've looked over the Locomotive and Express docs and couldn't pull it together. Any help is appreciated!
Thanks