For my university project, I am working on creating a basic login page. The challenge that I am facing is related to using Redis as the database for storing user credentials. Despite having a running Docker with the Redis image and establishing successful connections, I am finding it difficult to retrieve values from the Redis response.
In the code snippet provided below, I am attempting to toggle a boolean value from true to false based on the data associated with a specific key ('a'). However, no matter what adjustments I make, the value remains unchanged. It's important to note that I have limited experience in JavaScript and handling asynchronous functions in Redis API.
app.get('/enter', (req, res) => {
var username = req.query.user;
var password = req.query.pass;
ans = false
redis.get(username,function(err, reply) {
if(reply != null ) ans = true;
})
console.log(ans);
})
I'm simply trying to check if the key holds a value by testing variables before and after the request, yet the outcome doesn't reflect any changes made. Thank you for your assistance in this matter.