Now the next step is to create the application controller's:
Create a new file called
locations.js
insideapp/controllers/
and add the following code:var express = require('express'), router = express.Router(), mongoose = require('mongoose'), Location = mongoose.model('Location'); module.exports = function (app) { app.use('/', router); }; router.get('/locations', function (req, res, next) { Location.find(function (err, item) { if (err) return next(err); res.render('locations', { title: 'Locations', location: item, lat: -23.54312, long: -46.642748 }); //res.json(item); }); }); router.get('/locations/add', function (req, res, next) { res.render('add-location', { title: 'Insert Locations' }); }); router.post('/locations', function (req, res, next) { ...