We have answer of your question!

100% solved queries, no empty question

Question: Using Async inside another function [duplicate]


0

Advertisement


This question already has an answer here:

Question author Giuliog | Source

Answer


1


Advertisement


Using Node 6.0, in built Promises can be used.

convertProductfields: function (articlesFromAurelia){

    var allPromises = articlesFromAurelia
                      .map(post => new Promise((resolve, reject) => {
                               Categories.find({name: post.Categoria})
                                .then((category) => resolve(category))
                                .fail((error) => reject(error))
                               }));
    return Promise.all(allPromises);
}

And to use the above function,

convertProductfields(articlesFromAurelia)
  .then(() =>{
       //handle success
  }).catch(() => {
       //handle error
  })
Answer author Sainageswar-s

Advertisement


Tickanswer.com is providing the only single recommended solution of the question Using Async inside another function [duplicate] under the categories i.e javascript , node.js , asynchronous , sails.js , . Our team of experts filter the best solution for you.

Related Search Queries:

You may also add your answer!