title: node pass value to result function
body: <p>Here's how my code looks like</p>
  
  <pre><code>console.log(badgeList[i].id)  //will output the badgeList id
  
  BadgeTriggered.findOne({ schoolID: mongoose.mongo.ObjectId(schoolID), badgeID: mongoose.mongo.ObjectId(badgeList[i].id)}).then(function (err, data) {
      console.log("get data")
      console.log(data)
      console.log("and show badgeList below: ")
      console.log(badgeList[i].id)  //badgeList[i] is undefined here
  })
  </code></pre>
  
  <p>As you can see above, <code>badgeList[i]</code> is actually unavailable when I tried to print out the value inside the bottom console low. So how do I actually pass <code>badgeList</code> to the <code>findOne</code> result function?</p>