title: nodejs-Osmosis: how to pass results to other functions?
body: <p>I found this nodejs package and I have working code with correct results. But, I don't know how to pass these results to other functions. What I want is: get some info from web page, store it in variable, pass to onesignal function and send onesignal notification (I'm using onesignal-node package).
  This is my code now:</p>
  
  <pre><code>osmosis
  .get('url')
  .find('.content_body_left li')
  .set('day')
  .follow('a@href')
  .find('table tr')
  .delay(1000)
  .set({
    city: 'td[2]',
    street: 'td[3]',
    time:'td[4]'
  })
  .data(function(document) {
     var city = document['city'];  // &lt;== this variable I want to get
     return city;
  })
  var firstNotification = new OneSignal.Notification({
      contents: {
       // en: "test msg"
          en: city // &lt;== this is where I want to put variable
      }
  });
  </code></pre>
  
  <p>Problem is that I can't get <code>document['city'];</code> value out of <code>.data(function(document) { ... })</code> so I can't use it anywhere in my code.</p>
  
  <p>EDIT:
  I have this code also after <code>.data(function(document) { ... })</code></p>
  
  <pre><code>firstNotification.setIncludedSegments(['All']);
  firstNotification.setExcludedSegments(['Inactive Users']);
  firstNotification.setParameter('data', {"abc": "123", "foo": "bar"});
  myClient.sendNotification(firstNotification, function (err, httpResponse,data) {
     if (err) {
         console.log('Something went wrong...');
     } else {
         console.log(data, httpResponse.statusCode);
     }
  });
  </code></pre>
  
  <p>So, if I put <code>var firstNotification = new OneSignal.Notification({ ... });</code> it says: "firstNotification is not defined". But if I put all that code in  <code>.data(function(document) { ... })</code> or promise, it's working. But, is there any way to keep that other half of code out of .data (or promise)?</p>