I cant map array of objects eventhough it's printed in console.log
You need to check if the docs
property is not undefined. You can do that in a couple of ways:
You can use optional chaining to check if the property is not
null
orundefined
. Then your code will look like thisthis.props.results.data?.docs.map...
. Here's how you add it to your react app (but if you are using the latest babel version - it should work out of the box)You do the check yourself. The most basic one is, as suggested in the comment, is to check if the property is falsy:
this.props.results.data.docs && this.props.results.data.docs.map((data)
The comment is a bit incorrect though, you don't need to check if data
is falsy (only if the error is pointing at that), you check if docs
is falsy.