im getting the following errors Possible Unhandled Promise Rejection (id: 0): TypeError: user.slice is not a function. (In 'user.slice()', 'user.slice' is undefined)
I need the code to be able to pass the data too return the list of users in order of most matching elements to least. I was able to get the function working in replit with a made up data base once I try to put it in my project I am getting trouble, please help.
auth().onAuthStateChanged(user => {
if (user) {
// User is signed in, see docs for a list of available properties
// https://firebase.google.com/docs/reference/js/firebase.User
const profile = getUserProfile(user.uid);
profile.then(pro => {
const addy = pro.Address;
setAddress(pro.Address);
const filterdUsers = FBusers.filter(user => {
if(user.Address === addy && user.uid !== p pro.uid){
const items = new Set(pro)
const rank = arr => arr.filter(user => items.has(user)).length
return (a, b) => rank(b.items) - rank(a.items)
}
const sorted = user.slice().sort(filterdUsers(pro))
console.log(sorted.map(user => user.items.join(', ')))
}
)}};
// sort users
//setUsers(sortByMatch);
//vvv delete me vvv
setUsers(filterdUsers);
user is an object here and you can't slice an object. You can only slice an array or string