Cloud function check on component load

I need to perform a database check for users in my react-moralis app. The check needs to happen on component load. I’m calling cloud function like this:

const { data, id, error } = useMoralisCloudFunction(

and the cloud function looks like this:

Moralis.Cloud.define("getActiveFighter", async (request) => {
  	const logger = Moralis.Cloud.getLogger();
  	let userID =;
	const pointer = Moralis.User.createWithoutData(userID);
  	const ActiveFighters = Moralis.Object.extend("ActiveFighters");
    const query = new Moralis.Query(ActiveFighters);
    query.equalTo("User", pointer);
    const results = await query.find();
  	if(results.length > 0) {
      return results[0].get('FighterID');
    } else {
      return false;
}, {
  requireUser: true

The issue is that data returns undefined. What could be the issue? I’m sure that the cloud function returns the ID.

If you add there:

    const results = await query.find({useMasterKey : true});;

what you see in logs?

The cloud function is not the issue, I’ve tested it with logs and it returns the correct id like this:

2021-10-05T05:42:41.193Z - Ran cloud function getActiveFighter for user nm82fPaz4tKNv5DEOdtFIpw6 with:
  Input: {}
  Result: "21"

you also see in logs the request made from your react application?

I’m not sure where these logs are, but I’m sure the request is made since I can see it in Moralis Dashboard

Yep, I mean those logs from Moralis Dashboard.
I see this syntax in documentation:
const { data, error, isLoading } = useMoralisCloudFunction("topScores");
Not sure if it would make a difference