Hello,
I would like to use Moralis Cloud Function as an endpoint for my NFT metadata. This needs to return a precisely formatted JSON.
My cloud function look like this:
Moralis.Cloud.define("tokenURI", async (request) => {
const nftObject = Moralis.Object.extend("newNFTProposals");
const query = new Moralis.Query(nftObject);
query.equalTo("nftID", request.params.param1);
const result = await query.first();
const parsedResult = JSON.parse(JSON.stringify(result));
const metadata ={
"name": parsedResult.name,
"description": parsedResult.description,
"image": parsedResult.ipfs,
};
return metadata;
});
This almost works, except HTTP requests to the Cloud Functions returns as follows:
{ "result": { "name": "ARTIS", "description": "ArtisLife Network Token", "image": "https://ipfs.moralis.io:2053/ipfs/QmXY8MdL2kLDp7PgVEPMv5cD1XTinzpqDEpXHtK84yW8nk" } }
The desired result is:
{"name":"ARTIS","description":"ArtisLife Network Token","image":"https://ipfs.moralis.io:2053/ipfs/QmXY8MdL2kLDp7PgVEPMv5cD1XTinzpqDEpXHtK84yW8nk"}
Is there a way I can bypass the “result” object and return the metadata directly?
Thank you,
Adrian