I am having problem using cloud function

here is the error
Unhandled Rejection (Error): Invalid function: "fetchAllMemes"

15 | }, []); 16 | 17 | const fetchMemeOfTheDay = async () => {> 18 | let memes = await Moralis.Cloud.run(“fetchAllMemes”); | ^ 19 | // console.log(memes); 20 | 21 | //Filters out all memes by vote count of last 24hours!



THIS IS MY CLOUD FUNCTION


const fetchMemeOfTheDay = async () => {

  let memes = await Moralis.Cloud.run("fetchAllMemes");

  console.log(memes);

  let oneDay = 24 * 60 * 60 * 1000;

  console.log(oneDay);

  let posts = [];

  const filteredMemes = memes.filter((meme) => {

    return meme.voters.find((currentTimestamp) =>

      currentTimestamp.timestamp >= Date.now() - oneDay ? posts.push(meme) : ""

    );

  });

  console.log("FM", filteredMemes);

  const highestVotes = filteredMemes.sort((a, b) => {

    return b.voters.length - a.voters.length;

  });

  setRanking();

  setRanking(highestVotes);

};








ERROR FROM MY MORALIS DASBOARD

2022-01-27T17:46:06.997Z - Error: Invalid function: "fetchAllMemes"
    at handleCloudFunction (/moralis-server/lib/Routers/FunctionsRouter.js:119:13)
    at /moralis-server/lib/PromiseRouter.js:85:20
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

did you add that function in cloud code?

you can see here how to post code on forum: READ BEFORE POSTING - How to post code in the forum

Yes I added it on my moralis admin cloud code

const fetchMemeOfTheDay = async () => {

let memes = await Moralis.Cloud.run(“fetchAllMemes”);

console.log(memes);

let oneDay = 24 * 60 * 60 * 1000;

console.log(oneDay);

let posts = [];

const filteredMemes = memes.filter((meme) => {

return meme.voters.find((currentTimestamp) =>

  currentTimestamp.timestamp >= Date.now() - oneDay ? posts.push(meme) : ""

);

});

console.log(“FM”, filteredMemes);

const highestVotes = filteredMemes.sort((a, b) => {

return b.voters.length - a.voters.length;

});

setRanking();

setRanking(highestVotes);

};

I don’t understand what is the cloud code from there

What do you mean …that is exactly what I have on my

can you fist format the code that it is posted on forum? READ BEFORE POSTING - How to post code in the forum

for example this is not valid cloud code syntax

okay thank you, i have rewrite now, you can help to check again

it looks like you need to have this function in your cloud code: https://docs.moralis.io/moralis-server/cloud-code/cloud-functions

yes i have it on my moralis cloud function,

can you paste that code?
also can you paste your server subdomain/url