Skip to content
Advertisement

Axios Undefined Response

I am Developing MERN Stack Project. The problem is when I make the first API Call the first response is undefined and the map function gives an error ‘Map is not a function and it makes sense. the problem is i tried several approaches to prevent this from happening but it won’t work

JavaScript

This is the Code of the Component

Advertisement

Answer

Change

JavaScript

to

JavaScript

You were not setting the state to be an array on load

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement