Moralis.Cloud.define("getNFT", async (request) => {
const logger = Moralis.Cloud.getLogger();
let NFTId = request.params.nftId;
let hexId = parseInt(NFTId).toString(16);
let paddedHex = ("0000000000000000000000000000000000000000000000000000000000000000" + hexId).slice(-64)
let url = 'https://khnfrd2ukfku.usemoralis.com/' + paddedHex + '.json'
logger.info(url);
return Moralis.Cloud.httpRequest({url: url})
.then(function(httpResponse){
logger.info("SUCCESS");
logger.info("httpResponse:");
logger.info(httpResponse.data);
return httpResponse
}, function(httpResponse){
// error
logger.info("FAILURE");
logger.info('Request failed with response code ' + httpResponse.status);
})
})
Hey guys, hope you can help. Im trying to return the cloud function above but Im returning undefined. Is there anything that I need to be doing to get the json response back.
A couple notes:
- I was following a tutorial online and the code seems to be the same.
- The url looks correct, ive been copy/pasting it from the dashboard into the browser and it it directing me the the right place.
-The url is expected to return a json object. - I dont seem to be seeing any error logs or obvious issues in the dashboard
Thank you in advance,