Here is the code, I want to figure out how I can access all the passwords in the API(Data) to check if the password the user puts in is equal to any of the ones I get back from an API
I was using a loop but I figured it would take too long if the database got really large, if there is another way to do this please help me!
const Data = [{
id: 1
email: "ethan@gmail.com",
password: "hey1234"
},
{
id: 2
email: "gonz42@gmail.com",
password: "1234"
}
]
for (const iterator of Data) {
if (password !== iterator.password) {
console.log('please enter a password')
setPasswordError(true)
} else if(password === iterator.password) {
console.log('password is valid');
setPasswordError(false)
}else {
console.log('please enter a valid password')
}
}