Following the Neflix challenge and at the youtube section ‘Moralis DB and cloudfunctions’ (42mins-48mins) I keep getting the following error. Cannot seem to find the mistake, some help would be appreciated.
The error:
RESTController.js:438 Uncaught (in promise) Error: Cannot read properties of undefined (reading 'attributes')
at handleError (RESTController.js:438:1)
at async fetchMyList (Home.js:31:1)
VM1913:2 Uncaught ReferenceError: process is not defined
at Object.4043 (<anonymous>:2:13168)
at r (<anonymous>:2:306599)
at Object.8048 (<anonymous>:2:9496)
at r (<anonymous>:2:306599)
at Object.8641 (<anonymous>:2:1379)
at r (<anonymous>:2:306599)
at <anonymous>:2:315627
at <anonymous>:2:324225
at <anonymous>:2:324229
at HTMLIFrameElement.e.onload (index.js:1:1)```
My Cloud function
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 []
}
});
Home.js functions
const Home = () => {
const [visible, setVisible] = useState(false);
const [selectedFilm, setSelectedFilm] = useState();
const { isAuthenticated, Moralis, account } = useMoralis();
const [myMovies, setMyMovies] = useState();
useEffect(() => {
async function fetchMyList() {
await Moralis.start({
serverUrl: "https://oid22tonb...",
appId: "Sojukv0ZkWHJEo9pqURpjyzVQR...",
});
const theList = await Moralis.Cloud.run("getMyList", { addrs: account });
const filterdA = movies.filter(function (e) {
return theList.indexOf(e.Name) > -1;
});
setMyMovies(filterdA);
}
fetchMyList();
}, [account]);