Lemon Lemon - 6 months ago 3x
Javascript Question

Passing data from controller to another controller

I am working on sails JS application.

Is there anyway to pass a data from another controller using sails JS?

// controller 1
passing data to controller 2

// controller2

get data from controller 1

or better, is there anyway to create a global variable which can be accessed by any controller in sails js? just like $_SESSION['sessionname'] in php?


You can use a Service, it enables you to access data everywhere in your code.


You can also use the global variable sails:

sails.myObject = {}