Retrieve all the data from database

Hi, I am new to React and Moralis.
I am currently building a website and have run into some problems.

I want to retrieve all the data from one table. But I can’t achieve it and can’t find proper tutorials.

Here is the code:

import { useMoralis } from "react-moralis";
import { useEffect, useState } from "react";

export default function History() {
  const { Moralis } = useMoralis();

  const [histories, setHistories] = useState();

   useEffect(() => {
    async function getHistories() {
      const swapHistory = Moralis.Object.extend("SwapHistory");
      const query = new Moralis.Query(swapHistory);
      const histories = await query.find({ useMasterKey: true });
  }, []);

  return (
//  <div>looped list of histories<div/>

This code doesnt return a desired list, it returns:

0: ParseObjectSubclass {className: 'SwapHistory', _objCount: 2, id: 'ny63kiGSkT30U08DKL5t90vX'}
length: 1
[[Prototype]]: Array(0)

I want to show a list of all histories when I open the page, any solution would be welcome.

Your code looks ok. Looks like it is returning one result. How many results should histories have?

It only has 1 object, but how exactly can I get/retrieve a mutable and understandable list?

If you access your histories array, you can find the data inside attributes. Log it to console and open it to see what’s available.

This is what console.log(histories) looks like. Am I missing something? How to extract it?

Click on attributes at (...). This is where you can access the data in code as well.

Thank you bro, I got it. But why I have only one object there? How can I access all the entities?

query.find() as you have done will fetch all. Do you have multiple objects in your SwapHistory class? How many results should histories have?