You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Rendr middleware which load data for my application but I want to parse the parameters of the request for having the params array like in controllers.
var LocationsService = require('../../services/locations'),
PlacesService = require('../../services/places');
/**
* Middleware for data used by application
*/
module.exports = function(req, res, next) {
var app = req.rendrApp;
LocationsService.getLocationBySlug(app, 'paris-france', function(err, locationResult) {
if (err) {
return next(err);
}
var location = locationResult.location;
PlacesService.getPlacesByLocation(app, location.id, function(err, placesResult) {
if (err) {
return next(err);
}
var places = placesResult.places;
app.set('location', location);
app.set('places', places);
next();
});
});
};
the middleware runs before the router, so I don't think this is possible. We accomplish something very similar to this by adding the data to this.app in app.js's postInitialize method. For your case you could have a default controller that has a method you call from each of them to set the location/place data based on the params.
No description provided.
The text was updated successfully, but these errors were encountered: