Answer the question
In order to leave comments, you need to log in
How to catch synchronously data that is taken from redis?
Hello toasters.
The problem in general is this.
var data = [];
directions.forEach((direction) => {
var directionKey = direction.from+'-'+direction.to;
redisClient.get(directionKey, (err, reply) => {
if(err) next(err);
var decoded = JSON.parse(reply);
data.push({direction: decoded.direction, minMonthPrice: decoded.minMonthPrice.price});
});
});
console.log(data);
Answer the question
In order to leave comments, you need to log in
Once again, I found the answer to my own question.
For those who are interested, use multi in such situations, and then in exec process the array with the results.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question