The .map function is only available on array.
It looks like data isn't in the format you are expecting it to be
(it is {} but you are expecting []).
The "TypeError: map is not a function" occurs when we call the map() method on a value that is not an array. To solve the error, console.log the value you're calling the map() method on and make sure to only call map on valid arrays.
Here is an example of how the error occurs.
App.js
const App = () => {
const obj = {};
// ⛔️ Uncaught TypeError: map is not a function
return (
<div>
{obj.map(element => {
return <h2>{element}</h2>;
})}
</div>
);
};
export default App;
To solve the error, console.log the value you're calling the map method on and make sure it's a valid array.
App.js
export default function App() {
const arr = ['one', 'two', 'three'];
return (
<div>
{arr.map((element, index) => {
return (
<div key={index}>
<h2>{element}</h2>
</div>
);
})}
</div>
);
}