I am using redis stream with node js, I am facing issue when returning the async callback value. please give me suggestion on how I can return value below is my code
const redis = require('redis')
const redisClient = redis.createClient({
host: 127.0.0.1,
port: 6379
})
let array = []
let userCreated = await redisClient.xread(
'BLOCK',
0,
'STREAMS',
'user:created',
'$',
(err, str) => {
if (err) return console.error('Error reading from stream:', err)
str[0][1].forEach(message => {
id = message[0]
console.log(message[1])
return array.push(message[1]) // I get value here
})
return array
}
)
console.log(userCreated) "undefiend"