I am working on a practice login page in JS and JSON server as well as Axios. I am trying to verify that the username and password being entered are indeed on the DB. However it seems that even if I enter a username that I have already stored in the DB it will return as if it is false. Here is how I implemented it so far, this is before the password is checked for:
export const UseStorage = async (loginInfo) => {
var userLegit = true;
var passLegit = true;
try {
const response = await axios.get(`http://localhost:4000/users?user=${loginInfo.username.value}`);
console.log(response);
} catch (error) {
console.error('Not a valid username');
alert("Incorrect username or password. Please try again")
var userLegit = false;
console.log(userLegit)
}
The input is being taken in correctly on my form as I am also logging that before the function is ran, but the issue stems once I get into the actual search of the value within the function. Thanks for the help
"users": [
{
"pass": "123",
"user": "foobar",
"id": 1