TypeError: is not a function: How to Fix It | SheCodes

Wrong type · Usually quick to fix

TypeError: is not a function

Your code is trying to call something as a function, but it’s not a function. It might be undefined, a string, or an object.

What the error looks like

TypeError: data.map is not a function

Why it happens

This happens when a variable doesn’t contain what you expect. Maybe a function name is misspelled, or you’re calling .map() on something that isn’t an array.

How to fix it

  1. Check that the function name is spelled correctly
  2. Make sure you’re importing the function from the right place
  3. If using .map() or .filter(), make sure the data is actually an array

Ask your AI coding tool to fix it

Paste this prompt into Claude Code, Cursor, Bolt or Lovable, with your own error in place of the example.

I'm getting this error and I need help understanding and fixing it:

```
TypeError: data.map is not a function
```

Please:
1. Explain what this error means in plain English
2. Tell me the most likely cause
3. Give me the exact code changes or commands I need to fix it
4. Show me how to prevent this error in the future

Got a different error?

Paste any error into the free Error Decoder and get it explained in plain English, with a fix prompt.

Decode my error

More common errors explained