I am using redis list for storing the value for a key in nodeJS. I have made the following function and exported it to another file to make it a api:
async function set(id, ...seats) {
var seatArr = [];
for(var i = 0; i < seats.length; i++)
{
seatArr = seatArr.concat(seats[i]);
}
try{
result = await client.rpush('seats_'+id, ...seatArr);
} catch(err) {
console.log(err)
}
}
module.exports = {
set : set()
};
But I am getting the following error:
{ ReplyError: ERR wrong number of arguments for 'rpush' command
at parseError (/home/shivank/Music/node-app/ticket-booking/node_modules/redis-parser/lib/parser.js:179:12)
at parseType (/home/shivank/Music/node-app/ticket-booking/node_modules/redis-parser/lib/parser.js:302:14) command: 'RPUSH', args: [ 'seats_undefined' ], code: 'ERR' }
Please help me to resolve this.
rpushfor every item in the array? Seems to be two issues,idis undefined but this isn't why it's breaking, you can see that there is only one argument being passed toRPUSHyour...seatArrmust be empty