Hi Iâm seeing the error continue with cloud functions âgetMyListâ and âupdateListâ. When trying to add a movie to MyList, the page freezes.
2022-04-06T01:35:19.520Z - Error: Invalid function: âgetMyListâ
at handleCloudFunction (/moralis-server/lib/Routers/FunctionsRouter.js:126:13)
at /moralis-server/lib/PromiseRouter.js:85:20
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
2022-04-06T01:35:12.154Z - Error: Invalid function: âupdateMyListâ
at handleCloudFunction (/moralis-server/lib/Routers/FunctionsRouter.js:126:13)
at /moralis-server/lib/PromiseRouter.js:85:20
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)
Cloud Functions:
Moralis.Cloud.define(âgetMyListâ, async (request) => {
const addrs = request.params.addrs;
const user = Moralis.Object.extend("_User");
const query = new Moralis.Query(user);
query.equalTo(âethAddressâ, addrs);
const data = await query.first({ useMasterKey: true });
if(data.attributes.myList){
return data.attributes.myList;
}else {
return [];
}
});
Moralis.Cloud.define(âupdateMyListâ, async (request) => {
const addrs = request.params.addrs;
connst newFav = request.params.newFav;
const user = Moralis.Object.extend("_User");
const query = new Moralis.Query(user);
query.equalTo(âethAddressâ, addrs);
const data = await query.first({ useMasterKey: true });
if(data.attributes.myList){
const { myList } = data.attributes;
myList.push(newFav);
data.set(âmyListâ, myList)
}else {
data.set(âmyListâ, [newFav])
}
await data.save(null, {useMasterKey: true})
});