Here is my Moralis cloud function,
Moralis.Cloud.define("getUserInfo", async (request) => {
const query = new Moralis.Query("_User", { useMasterKey: true });
query.equalTo("accounts", request.params.ethAddress)
const results = await query.find({ useMasterKey: true });
return results;
});
When I call this cloud function using REST API,
let res = await axios.get(`https://jwwwh627aofffusemoralis.com:2053/server/functions/getUserInfo?_ApplicationId=iHfefwR5At8M27mMgdMxsgrd0izH5qx2F7wHVlðAddress=${params.ethAddress}`);
console.log("res", res.data);
Here is the response,
But, when I call this cloud using useMoralisCloudFunction
hook,
const params = { ethAddress: "0x5F8eac3eAeb7F32320ddb9B4433edD7A346d61065" };
const { fetch: getUserInfo } = useMoralisCloudFunction("getUserInfo", params, { autoFetch: false });
let userInfo = await getUserInfo();
console.log("userInfo", userInfo);
Here is the response,
Can anyone explain why this happens?