Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

262
Vistas
Whenever i try to use .map for fetching the data, i got error

whenever i try to fetch the data with .map function is show me the error

user.map is not a function

I use the below code for fetching the data

 user.map((user,index) => <>
         <h1> {user.name} </h1>
         <h1> {user.address} </h1>
     </>)

And use the below code for getting the data from backend,

  const [user, setUser] = useState([
{
    name:'',
    phone:'',
    bgroup:'',
    pincode:'',
    address:''
}
  ]);

useEffect(() => {
    fetch("/Donate").then(res=>{
        if(res.ok){
            return res.json();
        }
    }).then(jasonRes=>setUser(jasonRes));
},[])
  

With this , i get data in console , when i use the below code

 console.log(user)
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

const [user, setUser] = useState([]);
            
useEffect(() => {
  fetch("/Donate").then(res=>{
        if(res.ok){
            return res.json();
             }
        }).then(jasonRes=>setUser(jasonRes && jasonRes.Donate));
    },[])
        
     return (
        <>
          {user.map((el, i)=> {
            <div key={i}>
               <h1> {el.name} </h1>
                <h1> {el.address} </h1>
              </div>
           })}
       </>
  )
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda