Issue with creating Token and User columns for ItemsForSale [I CLONED RARABLE IN 24 HOURS pt12]

I cannot display the Token column and User column that links to their respected tables.
The cloud function i am using is:

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

  	const options = { address: request.params.token_address, chain: "ropsten" };
  	const NFTowners = await Moralis.Web3API.token.getNFTOwners(options);
  	const queryResults = NFTowners.result.filter(x => x.owner_of == request.user.attributes.accounts);
    const results = [];
 	for (let i = 0; i < queryResults.length; ++i) {
      results.push({
        "tokenObjectId": queryResults[i].id,
        "tokenid": queryResults[i].token_id,
        "tokenAddress": queryResults[i].token_address,
        "symbol": queryResults[i].symbol,
        "tokenUri": queryResults[i].token_uri,
      });
    }
    return results;
  });

Moralis.Cloud.beforeSave("ItemsForSale", async (request) => {
  
    const options = { address: "0x0dE601E38e2282AEDE397BF5c16B819000961301", chain: "ropsten" };
  	const NFTowners = await Moralis.Web3API.token.getNFTOwners(options);
    const queryResults = NFTowners.result.filter(x => x.token_address == request.object.get('tokenAddress') && x.token_id == request.object.get('tokenId'));
    //query.equalTo("token_address", request.object.get('tokenAddress'));
    //query.equalTo("token_id", request.object.get('tokenId'));
    const object = queryResults[0];
    if (object){
    	const owner = object.owner_of;
        const userQuery = new Moralis.Query(Moralis.User);
        userQuery.equalTo("accounts", owner);
        const userObject = await userQuery.first({useMasterKey:true});
        if (userObject){
            request.object.set('user', userObject);
        }
      	//request.object.set('token', object);
    }
  });

I am using Testnet Ropsten (Infura).

I had also tried the one provided here.

This there anywhere else i can be looking at?

Your title (creating token and user columns) is different from what you’ve said here:

I cannot display the Token column and User column that links to their respected tables.

What is your issue? Do you get any errors? Are you getting results from these cloud functions when you call them?

my issue is, im trying to make 2 columns in my ItemsForSale table: user (pointer <_User>) and token (Pointer < EthTransaction ).

I had used this code here for my cloud function:

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

  	const options = { address: request.params.token_address, chain: "ropsten" };
  	const NFTowners = await Moralis.Web3API.token.getNFTOwners(options);
  	const queryResults = NFTowners.result.filter(x => x.owner_of == request.user.attributes.accounts);
    const results = [];
 	for (let i = 0; i < queryResults.length; ++i) {
      results.push({
        "tokenObjectId": queryResults[i].id,
        "tokenid": queryResults[i].token_id,
        "tokenAddress": queryResults[i].token_address,
        "symbol": queryResults[i].symbol,
        "tokenUri": queryResults[i].token_uri,
      });
    }
    return results;
  });

Moralis.Cloud.beforeSave("ItemsForSale", async (request) => {
  
    const options = { address: "0x0dE601E38e2282AEDE397BF5c16B819000961301", chain: "ropsten" };
  	const NFTowners = await Moralis.Web3API.token.getNFTOwners(options);
    const queryResults = NFTowners.result.filter(x => x.token_address == request.object.get('tokenAddress') && x.token_id == request.object.get('tokenId'));
    //query.equalTo("token_address", request.object.get('tokenAddress'));
    //query.equalTo("token_id", request.object.get('tokenId'));
    const object = queryResults[0];
    if (object){
    	const owner = object.owner_of;
        const userQuery = new Moralis.Query(Moralis.User);
        userQuery.equalTo("accounts", owner);
        const userObject = await userQuery.first({useMasterKey:true});
        if (userObject){
            request.object.set('user', userObject);
        }
      	//request.object.set('token', object);
    }
  });

and this one here:

Problems with the collumns added in part 12 - rarible clone

Many other people have had my issue which ive tried following how they have fixed their issues, but i cannot seem to find anything to fix my issue.

No errors are displayed. NFTs are successfully minted and put into the Items table and ItemsForSale table but i cannot seem to display those 2 columns using the cloud function.

This is my Marketplace.sol file if that helps.

pragma solidity ^0.8.0;
//SPDX-License-Identifier: UNLICENSED
import "../node_modules/@openzeppelin/contracts/token/ERC721/IERC721.sol";

contract MorarableMarketContract {
    struct AuctionItem {
        uint256 id;
        address tokenAddress;
        uint256 tokenId;
        address payable seller;
        uint256 askingPrice;
        bool isSold;
    }

    AuctionItem[] public itemsForSale;
    mapping (address => mapping (uint256 => bool)) activeItems;

event itemAdded(uint256 id, uint256 tokenId, address tokenAddress, uint256 askingPrice);
event itemSold(uint256 id, address buyer, uint256 askingPrice);

modifier OnlyItemOwner(address tokenAddress, uint256 tokenId){
    IERC721 tokenContract = IERC721(tokenAddress);
    require(tokenContract.ownerOf(tokenId) == msg.sender);
    _;
}
modifier HasTransferApproval(address tokenAddress, uint256 tokenId){
    IERC721 tokenContract = IERC721(tokenAddress);
    require(tokenContract.getApproved(tokenId) == address(this));
    _;
}
modifier ItemExists(uint256 id){
    require(id < itemsForSale.length && itemsForSale[id].id == id, "could not find them");
    _;
}
modifier IsForSale(uint256 id){
    require(itemsForSale[id].isSold == false, "Item is already sold!");
    _;
}
function addItemToMarket(uint256 tokenId, address tokenAddress, uint256 askingPrice) OnlyItemOwner(tokenAddress,tokenId) HasTransferApproval(tokenAddress,tokenId) external returns (uint256){
    require(activeItems[tokenAddress][tokenId] == false, "Item is already up for sale!");
    uint256 newItemId = itemsForSale.length;
    itemsForSale.push(AuctionItem(newItemId, tokenAddress, tokenId, payable(msg.sender), askingPrice, false));
    activeItems[tokenAddress][tokenId] = true;


assert(itemsForSale[newItemId].id == newItemId);
emit itemAdded(newItemId, tokenId, tokenAddress, askingPrice);
return newItemId;
}

function buyItem(uint256 id) payable external ItemExists(id) IsForSale(id)HasTransferApproval(itemsForSale[id].tokenAddress,itemsForSale[id].tokenId){
    require(msg.value >= itemsForSale[id].askingPrice, "Not enough funds sent");
    require(msg.sender != itemsForSale[id].seller);

    itemsForSale[id].isSold = true;
    activeItems[itemsForSale[id].tokenAddress][itemsForSale[id].tokenId] = false;
    IERC721(itemsForSale[id].tokenAddress).safeTransferFrom(itemsForSale[id].seller, msg.sender, itemsForSale[id].tokenId);
    itemsForSale[id].seller.transfer(msg.value);

    emit itemSold(id, msg.sender,itemsForSale[id].askingPrice);
}
}



I would just like to know how i would implement this now compared to the Rarible clone tutorial.

You can create a relationship between the two classes. It looks like you are already trying that in your ItemsForSale by saving the user object in another object.

If you are getting data saved into your Items table, then you just need to query it. How are you trying to query it and display it in your app?