Jump to content
  • 0

Reaching a function or variable from another node/function



Hello, I have a question about how to reach a function or variable in a node/function from another one. Very basic fundamental stuff that I find a must to know now when I am starting out with working in the Lolo IDE.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 1

Great question! When working in the Lolo IDE we have access to something called route which you can find more info in the Lolo Docs about: https://docs.lolo.company/docs/applications. Route is used to pass events from one node to another by declaring:


in the end of your function. If you want to reach a specific variable or function that you declared in one node in a following node in your app you can do the following in the node where you declare your variable or function: 

exports.handler = async(ev, ctx) => {
  const { route } = ctx;

  //Declare your variable as usual
  const variable = "A variable I want to use in a later node/function";

  //Makes variable reachable through event
  ev.evvariable = variable;

  //Makes function reachable through event
  ev.evfunction = function exampleFunction() {
    //Do your function stuff as intended

  //Sends the events to following node/nodes.

Now to the node/function where you want to reach and use these variables or functions: 

exports.handler = async(ev, ctx) => {
  const {emit} = ctx;

  //Contains the string from previous node
  let body = ev.evvariable;
  //Emits a response containing the string
  emit('response', { statusCode: '200', body });
  //Contains previous nodes function and will execute it.

Remember this is only an example. The possibilities are endless. Hope this answered your question, and good luck in your Lolo Adventures!

Link to comment
Share on other sites

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...