1
I have the following structure in Node :
module.exports.find = function(pesquisa,frase){
return new Promise((resolve,reject) => {
pesquisa.find(frase, function(err,data){
if(err)
throw err;
else
resolve(data[0]['retorno']);
});
});
}
I’d like to do the search.find return a value to some variable where I could manipulate, or something like that.
Rods, I think this question is duplicated from this https://answall.com/q/140814/129. Take a look there.
– Sergio
I had seen but I could not get the correct answer, could you help me taking as an example my function? Got a little confused in the options of the other question
– rods
Where do you want to use
dados
? Can you give an example? Can you use callbacks? can you use Promises? can you use async/await? Sorry to bombard with questions, but it’s easier that way.– Sergio
This function is being called another page, I want to return the data to her , then if I have with the variable I can return it. I tried with Promisses but it appears pending. Ai i tried user o . then after promisse function and falls into the same problem.
– rods
Put that code with the trial code, I can explain what failed
– Sergio