this code is working it returns the previous data of the objects but it does not add the user it is empty
Moralis.Cloud.define('getNft', async function(){
const query = new Parse.Query('TokensMintedERC721')
const results = await query.find({ useMasterKey: true});
var newArr = []
async function getUser(element) {
const userPointer = element.get("user");
await userPointer.fetch({ useMasterKey: true});
let username = userPointer.get('username')
let userAvatar = userPointer.get('userAvatar')
// You can then get any value from the userPointer with userPointer.get('THE_VALUE')
return { username , userAvatar }
}
results.forEach( element => {
let { username, userAvatar } = getUser(element)
newArr = [...newArr, {...element, username: username, userAvatar: userAvatar }]
});
return newArr;
});
in the :
results.forEach( element => {
let { username, userAvatar } = getUser(element)
newArr = [...newArr, {...element, username: username, userAvatar: userAvatar }]
});
I have tried the following ways:
with ...elements
it works, it returns the data that exists, with the following it returns the empty objects without username and without userAvatar and with the last one, adding the name to the object and assigning the value also returns it empty
newArr = [...newArr, { username: username, userAvatar: userAvatar }]
newArr = [...newArr, {...element, }]
newArr = [...newArr, {...element, username, userAvatar}]