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 });
setHistories(histories);
}
getHistories();
}, []);
return (
// <div>looped list of histories<div/>
);
}
This code doesnt return a desired list, it returns:
[ParseObjectSubclass]
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.