i keep having the client is closed operation
i checked the documentations and i added “client.connect()’ the error went didn’t show up but my api responses weren’t coming through i asked gpt and according to it the line i added was the issue.
const client = redis.createClient();
client.connect();
client.on("error", function (error) {
console.error(error);
});
const setJWT = (key, value) => {
console.log(typeof key,typeof value)
return new Promise((resolve, reject) => {
try {
return client.set(key, value, (err, res) => {
if (err) reject(err);
resolve(res);
});
} catch (error) {
reject(error);
}
});
};
const getJWT = (key) => {
return new Promise((resolve, reject) => {
try {
client.get(key, (err, res) => {
if (err) reject(err);
resolve(res);
});
} catch (error) {
reject(error);
}
});
};
const deleteJWT = (key) => {
try {
client.del(key);
} catch (error) {
console.log(error);
}
};
module.exports = {
setJWT,
getJWT,
deleteJWT,
};
when i tried the await method it’s the same issue
New contributor
bruh xD is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.