Web3 Netflix Helping Each Other

this is my code in cloud moralis


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("ethAddres", addrs)
  
  	const data = await query.first({useMasterKey: true});
  	
  	if(data.attributes.myFavoriteList){
    	return data.attributes.myFavoriteList
      
    }else{
    	return []
    }
})

did you read this reply: Web3 Netflix Helping Each Other ?

1 Like

thank you very kind I have solved the problem thanks to your answers I can continue … thank you very much

2 Likes

Hello there, i am having problems with the library.js, can anyone help me pls? i cannot load the images
Now i could resolve it creating helpers folder, thanks anyways!)

Yes I am doing the netflix starter kit from github. And I am using Edge.

please try to provide the code in this way:

Carlos Z

1 Like

You should be using Chrome or Braves, also must have a metamask wallet installed to login with it.

Carlos Z

I’m having trouble with the IPFS video upload. I keep getting the

“Error: Request failed with status code 500”
message after trying to run node movie.js

let fs = require("fs");
let axios = require("axios");

let media = ["bikeride.mp4", "GOPR2525.MP4"];
let ipfsArray = [];
let promises = [];

for (let i = 0; i < media.length; i++) {
  promises.push(
    new Promise((res, rej) => {
      fs.readFile(`${__dirname}/export/${media[i]}`, (err, data) => {
        if (err) rej();
        ipfsArray.push({
          path: `media/${i}`,
          content: data.toString("base64"),
        });
        res();
      });
    })
  );
}
Promise.all(promises).then(() => {
  axios
    .post("https://deep-index.moralis.io/api/v2/ipfs/uploadFolder", ipfsArray, {
      headers: {
        "X-API-KEY": "redacted",
        "Content-Type": "application/json",
        accept: "application/json",
      },
      maxContentLength: Infinity,
      maxBodyLength: Infinity
    })
    .then((res) => {
      console.log(res.data);
    })
    .catch((error) => {
      console.log(error);
    });
});```

did you try it multiple times?
what is the size of those files that you try to upload?

Hi , I am have issues when adding the updateMyList function to my cloud functions.
without it getMyList function works but when i add updateMyList function I get the error
Error: Invalid function: “getMyList”

Cloud Function code

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;
  	const 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})

});

thanks :slight_smile:

this can happen when it is a syntax error somewhere in the code, or when cloud code updates, and in that case it happens for a short period of time

1 Like

The files I’m trying to upload are 230 MB and 88.5 MB.

I’ve tried a few times. I also tried to follow along with the IPFS section of the spotify demo Moralis Spotify Clone, as well as the guide from the Moralis IPFS Documentation page.

try with a file up to 50MB in size

Transcoded the files to smaller sizes (37MB and 26 MB). received this error in the terminal:

/Users/craigbarber/Developer/Upload/movie.js:17
                        content: data.toString("base64"),
                                      ^

TypeError: Cannot read properties of undefined (reading 'toString')
    at ReadFileContext.callback (/Users/craigbarber/Developer/Upload/movie.js:17:39)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (node:fs:314:13)

that error looks like data variable was not defined

Thanks. I’m still a bit new to coding and will go back and double check my code against the walk-through. I appreciate your help!

The issues was I didint end my if statement with } before the else statement.

everything works on my localhost but when deployed to vercel i am missinig the tabs. Any ideas?

Thanks for the help @cryptokid

https://netflix-lake.vercel.app/

1 Like

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})
});

You can get that error when there is a syntax error in cloud code or for a short period of time when cloud code updates. In case of a syntax error you should also see a red mark on your server in admin interface for that server.

Hi Moralis Mages,
I managed to complete the tutorial and made a small improvement to the login issue.
Here is the link to the repo: https://github.com/360Sch/Netflix-Decentralized

  1. To fix the login issue/bug, I added isAuthenticated as a dependency in useEffect
  2. Use .env to store the appId and serverUrl to keep the keys away from github with .gitignore
  3. Share my cloud functions code.

Hope it will help some of you in your progress. Thanks.

3 Likes