Hi, I want to ask if for testing servers (using ganache local) sometimes there not being rendered data.
Server; https://zjvbnysw1ygx.grandmoralis.com:2053/server
Code:
getAndRenderItemData = (item, renderFunction) => {
fetch(item.tokenUri)
.then(response => response.json())
.then(data => {
item.name = data.name;
item.description = data.description;
item.image = data.image;
item.type = data.type;
renderFunction(item);
})
}
loadItemsForSale = async () => {
const items = await Moralis.Cloud.run("getItemsForSale");
user = await Moralis.User.current();
items.forEach(item => {
if (user){
if (user.attributes.accounts.includes(item.ownerOf)){
const userItemListing = document.getElementById(`user-item-${item.tokenObjectId}`);
if (userItemListing) userItemListing.parentNode.removeChild(userItemListing);
getAndRenderItemData(item,renderUserItem);
return;
}
}
})
}
renderUserItem = async (item) => {
user = await Moralis.User.current();
const userItemListing = document.getElementById(`user-item-${item.tokenObjectId}`);
if (userItemListing) return;
const userInventory = userInventoryTemplate.cloneNode(true);
userInventory.getElementsByTagName("img")[0].src = item.image;
userInventory.getElementsByTagName("img")[0].alt = item.name;
userInventory.getElementsByTagName("img")[1].src = user.get('avatar').url();;
userInventory.getElementsByTagName("img")[1].alt = user.get('username');
userInventory.getElementsByTagName("h5")[0].innerText = item.name;
userInventory.getElementsByTagName("h6")[0].innerText = item.description;
userInventory.getElementsByTagName("span")[0].innerText = item.askingPrice;
userInventory.id = `user-item-${item.tokenObjectId}`
userInventories.appendChild(userInventory);
}
Because when I load sometimes they have price, sometimes they don’t. and the ordering are not the same maybe because some data loads faster some aren’t?