August 2016
Intermediate to advanced
376 pages
6h 33m
English
Now the next step is to create the application controller's:
locations.js inside app/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', ...