Cloud functions returning "data null"

Hi!

Server URL: https://fy10aag9l5fn.grandmoralis.com:2053/server

Probably it can be a logic error, this code worked well and all of the sudden started to retrieve - “TypeError: data is null”.

Even with ‘isLoading if’, suggested by Dmitry Yomoo in discord problem remains.

import { useMoralis, useMoralisCloudFunction } from "react-moralis";
import { Box, Container, Text } from "@chakra-ui/react";
import { ErrorBox } from "./Error";

const UniqueNFTOwners = () => {
  // https://github.com/MoralisWeb3/react-moralis#usemoraliscloudfunction
  const { data, error, isLoading } = useMoralisCloudFunction("uniqueNFTOwners");

  if (!isLoading) {
    console.log(JSON.stringify(data[0].NFT_UniqueOwners));

    return (
      <Container>
        {error != null ? (
          <ErrorBox title="Cloud function has failed" />
        ) : (
          <Text>
            Unique NFT Owners: {JSON.stringify(data[0].NFT_UniqueOwners)}
          </Text>
        )}
      </Container>
    );
  }
};

export const Home = () => {
  const { authenticate, isAuthenticated } = useMoralis();

  return (
    <Box>
      <UniqueNFTOwners />
    </Box>
  );
};

Help is needed!

Thanks in advance.

Best regards,
JoĂŁo Moreira

Hey @jmoreira

I just checked your logs and the result of your cloud function looks like:
[{"uniqueNFTOwners":355}]

So if you want to get the result from it your code should be like:

data[0].uniqueNFTOwners

JSON.stringify is not needed too