Cloud function error went to save

Moralis.Cloud.define("getUserItems", async (request) => {

  const query = new Moralis.Query("EthNFTTransfers");\
  query.equalTo("contract_type", "ERC721");
  query.containedIn("owner_of", request.user.attributes.accounts);
  const queryResults = await query.find();
  const result [];
  let sum = 0;
  for (let i = 0; i < queryResults.length; ++i) {
	result.push({
	  "id": queryResults[i].attributes.objectId,
      "tokenid": queryResults[i].attributes.token_id,
      "tokenaddress": queryResults[i].attributes.token_address,
      "symbol": queryResults[i].attributes.symbol,
      "tokenuri": queryResults[i].attributes.token_uri,

    });
  }  
  return results;
});

get error want i want so save at cloud

=>
const query = new Moralis.Query("EthNFTTransfers");
it looks like you have a \ at the end of line.

1 Like

after i removed it still get the problem

2021-10-16T08:46:01.859Z - SyntaxError: Unexpected identifier
at customUserPlugin (/moralis-server/cloud/main.js:107:26)
at /moralis-server/lib/cloud-code/plugins/index.js:72:15
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Object.initialize (/moralis-server/lib/cloud-code/plugins/index.js:61:3)

=> const result = []; maybe

Moralis.Cloud.define("getUserItems", async (request) => {

  const query = new Moralis.Query("EthNFTTransfers");
  query.equalTo("contract_type", "ERC721");
  query.containedIn("owner_of", request.user.attributes.accounts);
  const queryResults = await query.find();
  => const result = [];
  let sum = 0;
  for (let i = 0; i < queryResults.length; ++i) {
	result.push({
	  "id": queryResults[i].attributes.objectId,
      "tokenid": queryResults[i].attributes.token_id,
      "tokenaddress": queryResults[i].attributes.token_address,
      "symbol": queryResults[i].attributes.symbol,
      "tokenuri": queryResults[i].attributes.token_uri,

    });
  }  
  return results;
});

2021-10-16T09:31:15.883Z - SyntaxError: Unexpected identifier
at customUserPlugin (/moralis-server/cloud/main.js:107:26)
at /moralis-server/lib/cloud-code/plugins/index.js:72:15
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Object.initialize (/moralis-server/lib/cloud-code/plugins/index.js:61:3)

or i need reset new server

try:

Moralis.Cloud.define("getUserItems", async (request) => {

  const query = new Moralis.Query("EthNFTTransfers");
  query.equalTo("contract_type", "ERC721");
  query.containedIn("owner_of", request.user.attributes.accounts);
  const queryResults = await query.find();
  const result = [];
  let sum = 0;
  for (let i = 0; i < queryResults.length; ++i) {
	result.push({
	  "id": queryResults[i].attributes.objectId,
      "tokenid": queryResults[i].attributes.token_id,
      "tokenaddress": queryResults[i].attributes.token_address,
      "symbol": queryResults[i].attributes.symbol,
      "tokenuri": queryResults[i].attributes.token_uri,

    });
  }  
  return results;
});