token uri https://ipfs.moralis.io:2053/ipfs/QmdFfRraiNPbJ4PcTJ8AoXe37ixvkAZJ4JZp3tRCc15j3G
right now itâs just in pending balance as I said no errors shows in console only that itâs pending.
token uri https://ipfs.moralis.io:2053/ipfs/QmdFfRraiNPbJ4PcTJ8AoXe37ixvkAZJ4JZp3tRCc15j3G
right now itâs just in pending balance as I said no errors shows in console only that itâs pending.
ok, tested this and it looks to work:
Moralis.Cloud.define("get_token_uri", (request) => {
let url = "https://ipfs.moralis.io:2053/ipfs/QmdFfRraiNPbJ4PcTJ8AoXe37ixvkAZJ4JZp3tRCc15j3G";
return Moralis.Cloud.httpRequest({
"url": url,
"headers": {
'method': 'GET',
'accept': 'application/json'
}
}).then(function(httpResponse){
return httpResponse.data;
},function(httpResponse){
logger.info("error");
logger.info(httpResponse);
});
});
mine doesnât even if I put it on itâs own function this is the error Iâm getting now when I run it
2021-10-18T17:49:30.738Z - Error: Invalid function: âget_token_metadataâ
at handleCloudFunction (/moralis-server/lib/Routers/FunctionsRouter.js:119:13)
at /moralis-server/lib/PromiseRouter.js:85:20
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Maybe there is some error somewhere, if you add my function in you cloud code I expect it to work.
as I said I did add it exactly same with static url still same result
If you copy exactly my code you get that error? Other functions work well?
yes
2021-10-18T18:32:18.462Z - Error: Invalid function: âget_token_uriâ
at handleCloudFunction (/moralis-server/lib/Routers/FunctionsRouter.js:119:13)
at /moralis-server/lib/PromiseRouter.js:85:20
at processTicksAndRejections (internal/process/task_queues.js:95:5)
Strange, are you sure you are connected to the right Moralis server? You get same error if you put there a random function name?
yes sure itâs the correct server Iâm just initiating and running from console at this point
this does work anyway so I might just change my before save to include it.
Moralis.Cloud.define(âtestMetadataâ, async (request) => {
const { chain, tokenAddress, tokenId, } = request.params;
return await Moralis.Web3API.token.getTokenIdMetadata({ address: tokenAddress, token_id: tokenId, chain: chain}).then((result) => {
return result;
});
});
well now trying to incorportate the very same code into the before save results in
{ânameâ:âBlockchain Factoryâ,âsymbolâ:âBLCKCHNâ,âtoken_uriâ:âhttps://ipfs.moralis.io:2053/ipfs/QmWantQC68Re6vWpn1PktgtGJoe1mPEJ71yvNdatys1j1K",âtoken_idâ:â124â,âtoken_addressâ:â0x668aed884e1ebfa5dab26fc80ab0f8ecea59aa2bâ,âowner_ofâ:â0x4771ff1f558b3cc9996ec030fca95fd672425ef6â,âblock_numberâ:13343001,âamountâ:â1â,âcontract_typeâ:"ERC721â} Error: {âmessageâ:"[object Object]",âcodeâ:141}
here is the beforeSave()
Moralis.Cloud.beforeSave(âBscNFTOwnersâ, async (request) => {
const tokenAddress = request.object.get(âtoken_addressâ);
const tokenId = request.object.get(âtoken_idâ);
const tokenUri = request.object.get(âtoken_uriâ);
if (!tokenUri) return;
// var dataFromURI = await httpGet(tokenUri);
var dataFromURI = await Moralis.Web3API.token.getTokenIdMetadata({ address: tokenAddress, token_id: tokenId, chain: âbsc testnetâ}).then((result) => {
return result.metadata;
});
request.object.set("metadata", dataFromURI);
});
you could add some lines with logger.info(JSON.stringify(variable_name));
to see how far it gets in execution
even with ur code itâs not returning anything useful here is a sample
the result could also depend on the url that it tries to access, sometimes that url could not work
except that all and every URL which is just files on the server itself btw not working Iâm kind of giving up here this is killing the site that is using it already.
Can you add more logging? like the url that it is tried to get accessed before it tries to access it.
That is what is only returning from your function with added URL Logging.
logger.info(âerrorâ);
logger.info(tokenUri);
logger.info(httpResponse);
I doesnât look good, can you paste the function that you use now?
function httpGet2(url) {
return Moralis.Cloud.httpRequest({
"url": url,
"headers": {
'method': 'GET',
'accept': 'application/json'
}
}).then(function(httpResponse){
return httpResponse.data;
},function(httpResponse){
logger.info("error");
logger.info(url);
logger.info(httpResponse);
});
}
async function httpGet2(url) {
return await Moralis.Cloud.httpRequest({
url: url,
headers: {
method: "GET",
accept: "application/json",
},
})
.then((httpResponse) => httpResponse.data)
.catch((error) => logger.info(error));
}