I’ve been tried to use this method but in the FE it say “undefined”
In my Cloud Function
Moralis.Cloud.define("getAllPost", async(request) => {
const query = new Moralis.Query("Post");
query.descending("createdAt");
query.include(["writer.username"]);
const results = await query.find();
return results;
})
In my javascript
async getAllPost({ commit }) {
const params = {};
try {
const response = await Moralis.Cloud.run("getAllPost", params);
response.forEach((data) => {
console.log("Get the username : ", data.get("username"));
});
commit("setPosts", response);
} catch (error) {
const code = error.code;
const message = error.message;
console.log(code, message);
}
},