I’m trying to use this from within a cloud function:
Moralis.Cloud.define('getNFTMetadata', async (req) => {
const chain = req.params.chain;
const address = req.params.address;
const token_id = req.params.tokenId;
const options = { address, token_id, chain };
const tokenIdMetadata = await Moralis.Web3API.token.getTokenIdMetadata(options);
return tokenIdMetadata;
});
I saw on another post that I’d most likely would need to use the REST API, so now I’m calling it like this:
Moralis.Cloud.define('getNFTMetadata', async (req) => {
const chain = req.params.chain;
const address = req.params.address;
const token_id = req.params.tokenId;
const options = { address, token_id, chain };
const tokenIdMetadata = await Moralis.Cloud.httpRequest({
url: "https://deep-index.moralis.io/api/v2/nft/" + address + "/" + token_id + "?chain=" + chain,
headers: {
"x-api-key": "xxxx"
}
});
return tokenIdMetadata;
});