Question

How can I use send() in action of controller in locomotive Js. I think LCM only provides render(). Can some one guide me in this regards.

Était-ce utile?

La solution

Locomotivejs is just an extension of Express, meaning a Loco app is an Express app. From the docs:

Request and Response

If an application needs access to the raw request and response, each is available as an instance variable within the controller.

PhotosController.show = function() {
  var req = this.req;  // also aliased as this.request
  var res = this.res;  // also aliased as this.response
  this.render();
}

So from within your controller, simply:

MyController.myAction = function () {
  this.res.send(200);
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top