sails.js Controllers ES2015 Syntax


'use strict';

// This is an example of a /api/controllers/HomeController.js
module.exports = {
  // This is the index action and the route is mapped via /config/routes.js
  index(req, res) {
    // Return a view without view model data
    // This typically will return the view defined at /views/home/index.<view engine extension>
    return res.view();
  foo(req, res) {
    // Return the 'foo' view with a view model that has a `bar` variable set to the query string variable `foobar`
    return res.view({
      bar: req.param('foobar'),