Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

85
Vistas
react native possible uhandled promise rejection

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);

7 months ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

user is an object here and you can't slice an object. You can only slice an array or string

JavaScript Array Slice()

JavaScript String slice()

7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos