1

I have a jsonData (objects in array), and I am using map function to get completely new data.
So basically, eachData becomes newEachData.
My code looks like this:

let jsonData = data.toJSON();
let newData = jsonData.map((**eachData**) => {
   User.query({
      where: {userid: eachData.userid_b},
      select: ['username', 'userid']
   }).fetch().then(userData => {
      let **newEachData** = userData.toJSON();
   })
})
console.log(newData);

How to return new value?

Just to be clear, I am retrieving new data from database using eachData right after map function.

Sunil Kumar
  • 3,142
  • 1
  • 19
  • 33
kay
  • 1,369
  • 4
  • 15
  • 27
  • I'm curious how you're able to `map` a JSON string in the first place…? (I'm assuming `.toJSON()` returns JSON…?) – deceze Oct 18 '16 at 14:03

0 Answers0