Hi I have JSON file that have users nickname, password and token. I'm using a find function to find users from their nicknames. I want to get tokens too.
[
{
"user": [
"bombali",
"reYiz_2031",
"GcjSdUMp"
]
},
{
"user": [
"johndoe",
"testpasswd1_s",
"SdNFccRT"
]
}
]
This is my JSON data file.
I'm checking if nicname is taken or not using this code:
function isUsernameTaken(username) {
const user_Database = require(`${config.path_users}`);
const finded_Name = user_Database.find(
({ user }) => user[0] === username.toLowerCase()
);
if (finded_Name === undefined) {
console.log("This username is usable");
} else {
console.log("This username is unusable");
}
}
Now I want to get token from json by using username and password to use filter. I don't want to use token:SdNFccRT in array. Is it possible? Thanks for all replies.