Hey guys! I’m using a Cloud Function to query the “Projects” object in my Moralis server. One of the attributes for Projects is “creator” which links to the user in the Moralis database who created the project. When I try to query the “username” and “profilePic” attributes from the “creator” they are returned as undefined. I noticed in the console next to creator the word “ParseUser” and then the attributes listed below. When I run the query through the browser I am able to access this data. How can I call this data in the ParseUser and ParseFile in a cloud function?
I hope this was clear. Thank you
Here is the cloud function:
Moralis.Cloud.define("renderProjects", async (request) => {
const query = new Moralis.Query("Projects");
const queryResults = await query.find();
const results = [];
for (let i = 0; i < queryResults.length; ++i) {
results.push({
"creator": queryResults[i].attributes.creator,
//username returns as undefined
"username": queryResults[i].attributes.creator.attributes.username,
//profilePic returns as undefined
"profilePic": queryResults[i].attributes.creator.attributes.profilePic._url,
"title": queryResults[i].attributes.title,
"projectPhoto": queryResults[i].attributes.projectPhoto._url,
"summary": queryResults[i].attributes.summary,
"createdAt": queryResults[i].attributes.createdAt,
"description": queryResults[i].attributes.description,
});
}
return results;
});
Here is a screen shot of the console showing ParseUser next to creator