Within my code, I attempted to retrieve users with the role of Admin and only their usernames from the API JSON data. However, I encountered an issue where it did not work as expected.
"response": [
{
"profile_picture": "",
"verified_by_email": false,
"_id": "61c3a765c5f55200049de490",
"username": "user2",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="83f6f0e6f1b2c3fae2ebececade0ecee">[email protected]</a>",
"password": "$2a$10$pMOyjwVf1RkaIeVdNKWdaucVRybsDEEN3fjxLZOctJyL42HqrlRgC",
"role": "User",
"phone_number": "12365478",
"createdAt": "2021-12-22T22:32:05.034Z",
"updatedAt": "2021-12-22T22:32:05.034Z",
"__v": 0
},
{
"profile_picture": "",
"verified_by_email": false,
"_id": "61c325ea02526b000424929f",
"username": "nina",
"email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="97f9fef9d7eef6fff8f8b9f4f8fa">[email protected]</a>",
"password": "$2a$10$steP5Aq9mcTIA8XLjm9Y5ONoWQUMEWLD7TJPSHzTksqbOTpv9MbD.",
"role": "Admin",
"phone_number": "123456",
"createdAt": "2021-12-22T13:19:38.240Z",
"updatedAt": "2021-12-22T13:19:38.240Z",
"__v": 0
}
]
}
computed:{
getAdmin(){
// I stored the API response in the Users array
this.Users.filter(users => {
return users.role;
}
}
}