skip to Main Content

In Reactjs Getting an error .map() is not a function – Javascript

when i try to fetch response from api i got map is not a function error .but i declared state as array. Here's the code: function VendorListScreen(){ const [vendorsList,setVendorsList]=useState([]); const getVendors =()=>{ axios.get('http://127.0.0.1:8000/api/vendors/').then((res)=>{ setVendorsList(res.data) }) } <h1>Vendor</h1> <button onClick={getVendors}>get</button> {vendorsList.map(vendor=>{…

VIEW QUESTION

Filtering Objects in Arrays (JavaScript)

Could someone help me understand why: const people = [{ name: "Carly", yearOfBirth: 1942, yearOfDeath: 1970, }, { name: "Ray", yearOfBirth: 1962, yearOfDeath: 2011, }, { name: "Jane", yearOfBirth: 1912, yearOfDeath: 1941, }, ]; const findTheOldest = function(array) { let…

VIEW QUESTION
Back To Top
Search