Hi, the logger is not displaying anything, also I’m trying to pass 1 element from the results of the query and whenever I try to transfer 1 data to another array, it’s not transferring properly. What happened is that all the data is being passed.
I’m trying to transfer 1 data from the “results” to testResults.
Expected output
results = [{ “test”: “test”, “test2”, “test2”}]
testResults[0] = results[0];
testResult = {“test”: “test”}
What I got is
testResult = [{ “test”: “test”, “test2”, “test2”}]
Moralis.Cloud.define("getUserNFT", async (request) => {
const query = new Moralis.Query("EthNFTOwners");
query.equalTo("contract_type", "ERC721");
if(request.user.get("accounts")){
query.containedIn("owner_of", request.user.get("accounts"));
const queryResults = await query.find();
const results = [];
for(let i = 0; i < queryResults.length; ++i){
results.push({
"tokenObjectId": queryResults[i].id,
"tokenId": queryResults[i].attributes.token_id,
"tokenAddress": queryResults[i].attributes.token_address,
"symbol": queryResults[i].attributes.symbol,
"tokenUri": queryResults[i].attributes.token_uri
});
}
const testResults = [];
testResults[0] = results[0];
const logger = Moralis.Cloud.getLogger();
logger.info(results);
logger.info("results",JSON.stringify(results))
logger.info("results first element of array: ",JSON.stringify(results[0]))
return results;
}
return;
});