I'm trying to insert the data fetched into a map function that returns each employe's name in
, but im getting an error that says "data.map is not a function". How can I fix this>import React, { useState, useEffect } from "react";
//const data = [{id:1,employee_name:"Tiger Nixon",employee_salary:320800,employee_age:61,profile_image:""},{id:2,employee_name:"Garrett Winters",employee_salary:170750,employee_age:63,profile_image:""}]
export default function App() {
const [data, setData] = useState([]);
useEffect(() => {
fetch("https://dummy.restapiexample.com/api/v1/employees")
.then(response => response.json())
.then(result => setData(result))
},[]);
const information = data.map((item,i) => {
return (<h1> item.employee_name </h1>);
})
return (
<div className="App">
<h1> {information} </h1>
<h2>Start editing to see some magic happen!</h2>
</div>
);
}
datato see what it actually is when the error prints?