Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!