简体   繁体   中英

How to use send in Locomotive Js

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.

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM