I’m trying to store a game score in the moralis server via cloud code, I’ve been able to get some data to pass and store but not the score not sure what Im doing wrong here is my javascript code:
setScore = async(points) => {
currentSwanHolder = await Moralis.User.current();
//let Points = parseInt(points);
const params = {
"player": currentSwanHolder.get('ethAddress'),
"score" : points
};
const saveIt = await Moralis.Cloud.run('saveScore', params);
}
here is my cloud code
Moralis.Cloud.define("saveScore", async(res) =>{
const Score = Moralis.Object.extend("swanHunters");
const score = new Score();
score.set("player", res.params.player);
score.set("score", res.params.points);
score.save(null, { useMasterKey: true});
return true
});
I can do this just fine if I don’t use a cloud function, updating storing user address and score but not as a cloud function only the user address is saved.