Edit Page

Request (req)

Sails is built on Express, and uses Node's HTTP server conventions. Because of this, you can access all of the Node and Express methods and properties on the req object wherever it is accessible (in your controllers, policies, and custom responses).

A nice side effect of this compatibility is that, in many cases, you can paste existing Node.js code into a Sails app and it will work. And since Sails implements a transport-agnostic request interpreter, the code in your Sails app is WebSocket-compatible as well.

Sails adds a few methods and properties of its own to the req object, like req.wantsJSON and req.allParams(). These features are syntactic sugar on top of the underlying implementation, and also support both HTTP and WebSockets.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.

Reference

Reference