Mapping an array of Moralis objects uploaded by the user in the front-end

Hey Moralis community! I am trying to map through objects in my database to the front end in ReactJS, but I’m getting this error: TypeError: Cannot read properties of undefined (reading 'map')

When I console.log(className) or console.log([className]) as an array, it’s logged in the console as undefined. However, I have 3 objects that I’ve successfully uploaded to the Moralis db.

Is there something wrong with how I am mapping the objects?

{className.map((className) => (
                <div>
                    <h1>
                        Info Here {className.id} by {className.createdBy} with {className.prop1} and {className.prop2 ? "yes" : "no"}
                    </h1>
                </div>
            ))} 

if console.log(className) doesn’t work, then probably that map doesn’t work either.

True true…is there a reference on how to map objects from Moralis in JavaScript? I couldn’t find it in the docs or forum. Maybe I was looking in the wrong places.

I think that first you have to get that data somehow, before you try to use map or other option to iterate it.

You may need to use useState, useEffect hooks in react if you didn’t use them already, or how did you initialise that variable named className ?