[SOLVED] How to retrieve all objects data in Moralis Database

If this doesn’t work, Prolly, there’s an inaccurate spacing in the name in the DB. You should check for that too

1 Like

If you try the GET request in an app like Postman or even in the browser it will show you the proper response.

Console.log on the results gives you those objects. You can try to map the results and get the attributes for each one.

You can also filter the results to give you only the columns you need and chain them together and try find()

What exact query do you need?

import { useMoralisQuery, useMoralis } from "react-moralis"

export default function ComponentName() {
const { isWeb3Enabled } = useMoralis();

let walletAddress = "0x....."

const { data, isFetching } = useMoralisQuery(
    "Membership",
    query => query.select('name', 'creator', 'cost', 'count').equalTo("creator", walletAddress).find() // remove .find() if that doesn't work
  );

  console.log("FETCHED DATA", data)

  // .attributes will show your the column data returned for each result
  return (
    <div className="flex flex-wrap gap-4">
        {isWeb3Enabled ? (
            isFetching ? (
                <div>Loading...</div>
            ) : (
                data.map((membership) => {
                    console.log(membership.attributes); 
                    return (
                      <div></div> // map your data
                    )
                })
            )
        ) : (
            <div>Web3 Currently Not Enabled</div>
        )}
      </div>
  );
}
1 Like

thank you so much for giving me the example, now i’ve managed to query the data i want.
thank you for all of your support. really appreciate it!

1 Like