I made a cloud function word for word as per this video
When I try to run it, I run into this error
I donât see the error, did you include it?
yes. I tried as a gist. Here is the error
|2021-10-09T18:51:13.253Z - Error: [object Object]|
||at Object.resolveError (/moralis-server/lib/triggers.js:631:17)|
||at error (/moralis-server/lib/Routers/FunctionsRouter.js:107:32)|
||at runMicrotasks ()|
||at processTicksAndRejections (internal/process/task_queues.js:95:5)|
||2021-10-09T18:51:13.250Z - Failed running cloud function getNFT for user undefined with:|
||Input: {"_ApplicationId":âEcXFhXVLhnGqUZNx9h8IyhtbZfwZCHYKbyIIlcZ3â,ânftIdâ:â0â}|
||Error: {âmessageâ:{âstatusâ:404,âheadersâ:{âdateâ:âSat, 09 Oct 2021 18:51:13 GMTâ,âcontent-typeâ:âtext/htmlâ,âtransfer-encodingâ:âchunkedâ,âconnectionâ:âcloseâ,âcf-cache-statusâ:âDYNAMICâ,âexpect-ctâ:âmax-age=604800, report-uri=âhttps://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ctââ,âreport-toâ:"{âendpointsâ:[{âurlâ:âhttps:\/\/a.nel.cloudflare.com\/report\/v3?s=VnXhR0xhgYARcCtjx3lxlW4sbcgOCbhy6nnPYJtPnuC4e2BFeSGWdppTx8oBXJJ7Vk2FrgjGRMREdUfQyhcZMtrtN8sdx4NaohMNwy3i%2BWZkeMPwXDnoxE3pMFTym%2FCrQabu6HMozC7nQYVrh4k%3Dâ}],âgroupâ:âcf-nelâ,âmax_ageâ:604800}",ânelâ:"{âsuccess_fractionâ:0,âreport_toâ:âcf-nelâ,âmax_ageâ:604800}",âserverâ:âcloudflareâ,âcf-rayâ:â69b9cc8faf03fa48-AMSâ},âbufferâ:{âtypeâ:âBufferâ,âdataâ:[60,104,116,109,108,62,13,10,60,104,101,97,100,62,60,116,105,116,108,101,62,52,48,52,32,78,111,116,32,70,111,117,110,100,60,47,116,105,116,108,101,62,60,47,104,101,97,100,62,13,10,60,98,111,100,121,62,13,10,60,99,101,110,116,101,114,62,60,104,49,62,52,48,52,32,78,111,116,32,70,111,117,110,100,60,47,104,49,62,60,47,99,101,110,116,101,114,62,13,10,60,104,114,62,60,99,101,110,116,101,114,62,110,103,105,110,120,47,49,46,49,56,46,48,32,40,85,98,117,110,116,117,41,60,47,99,101,110,116,101,114,62,13,10,60,47,98,111,100,121,62,13,10,60,47,104,116,109,108,62,13,10]},âtextâ:"\r\n404 Not Found\r\n\r\n
it looks like that error says:
<html>
<head><title>404 Not Found</title></head>
<body>
<center><h1>404 Not Found</h1></center>
<hr><center>nginx/1.18.0 (Ubuntu)</center>
</body>
</html>
yes, that entire error looks to say that it was a not found error somewhere, maybe the cloud function tried to read a url
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)
logger.info(paddedHex);
return Moralis.Cloud.httpRequest({url: âhttps://cr7ge1kve9u7.moralishost.com/{id}.jsonâ + paddedHex + â.jsonâ})
.then(function(httpResponse){
return httpResponse.text;
})
})
This is the function. It was working before
is that url accessible now?
what link you try to access there?
yes it works
I corrected this line
return Moralis.Cloud.httpRequest({url: âhttps://cr7ge1kve9u7.moralishost.com/{id}.jsonâ + paddedHex + â.jsonâ})
It is supposed to be
return Moralis.Cloud.httpRequest({url: âhttps://cr7ge1kve9u7.moralishost.com/â + paddedHex + â.jsonâ})
Still saying not found
you can log that url before trying to access it, to make sure has the right value
i did logger.info(httpResponse) but the same output even after restarting the server
2021-10-09T20:12:46.164Z - Error: [object Object]
at Object.resolveError (/moralis-server/lib/triggers.js:631:17)
at error (/moralis-server/lib/Routers/FunctionsRouter.js:107:32)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
2021-10-09T20:12:46.157Z - Failed running cloud function getNFT for user undefined with:
Input: {"_ApplicationId":âEcXFhXVLhnGqUZNx9h8IyhtbZfwZCHYKbyIIlcZ3â,ânftIdâ:â1â}
Error: {âmessageâ:{âstatusâ:404,âheadersâ:{âdateâ:âSat, 09 Oct 2021 20:12:46 GMTâ,âcontent-typeâ:âtext/htmlâ,âtransfer-encodingâ:âchunkedâ,âconnectionâ:âcloseâ,âcf-cache-statusâ:âDYNAMICâ,âexpect-ctâ:âmax-age=604800, report-uri=âhttps://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ctââ,âreport-toâ:"{âendpointsâ:[{âurlâ:âhttps:\/\/a.nel.cloudflare.com\/report\/v3?s=d3laPWLOQ5H2QQMHRqhA9Rl6A45muB4k8MRJxAEkUJchxsoUNpkBE0l5j9lFtqemK7UnFeviT6u56AssboN7Uf3WPE%2FnSHmUGA%2Btf305Z1PmvsAr6rWlwF4KFiS01m01wsy%2FZQNwN8pLbGSJOHo%3Dâ}],âgroupâ:âcf-nelâ,âmax_ageâ:604800}",ânelâ:"{âsuccess_fractionâ:0,âreport_toâ:âcf-nelâ,âmax_ageâ:604800}",âserverâ:âcloudflareâ,âcf-rayâ:â69ba44044b231e81-AMSâ},âbufferâ:{âtypeâ:âBufferâ,âdataâ:[60,104,116,109,108,62,13,10,60,104,101,97,100,62,60,116,105,116,108,101,62,52,48,52,32,78,111,116,32,70,111,117,110,100,60,47,116,105,116,108,101,62,60,47,104,101,97,100,62,13,10,60,98,111,100,121,62,13,10,60,99,101,110,116,101,114,62,60,104,49,62,52,48,52,32,78,111,116,32,70,111,117,110,100,60,47,104,49,62,60,47,99,101,110,116,101,114,62,13,10,60,104,114,62,60,99,101,110,116,101,114,62,110,103,105,110,120,47,49,46,49,56,46,48,32,40,85,98,117,110,116,117,41,60,47,99,101,110,116,101,114,62,13,10,60,47,98,111,100,121,62,13,10,60,47,104,116,109,108,62,13,10]},âtextâ:"\r\n404 Not Found\r\n\r\n
How do i clear the moralis log?
you should log the parameter to Moralis.Cloud.httpRequest
, to see what it tries to access there
the response to Moralis.Cloud.httpRequest is httpResponse correct?
logger.info(Moralis.Cloud.httpRequest)?
How do i clear the Moralis log, the same error has come up and the time zone is different from where I stay to the point I cannot make out if it is the latest error or no log
I think it ran once correctly
2021-10-09T20:23:51.296Z - Error: [object Object]
at Object.resolveError (/moralis-server/lib/triggers.js:631:17)
at error (/moralis-server/lib/Routers/FunctionsRouter.js:107:32)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:95:5)
2021-10-09T20:23:51.291Z - Failed running cloud function getNFT for user undefined with:
Input: {"_ApplicationId":âEcXFhXVLhnGqUZNx9h8IyhtbZfwZCHYKbyIIlcZ3â,ânftIdâ:â1â}
Error: {âmessageâ:{âstatusâ:404,âheadersâ:{âdateâ:âSat, 09 Oct 2021 20:23:51 GMTâ,âcontent-typeâ:âtext/htmlâ,âtransfer-encodingâ:âchunkedâ,âconnectionâ:âcloseâ,âcf-cache-statusâ:âDYNAMICâ,âexpect-ctâ:âmax-age=604800, report-uri=âhttps://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ctââ,âreport-toâ:"{âendpointsâ:[{âurlâ:âhttps:\/\/a.nel.cloudflare.com\/report\/v3?s=giw7SQKxxwy2TVVc3EzQPv%2B6O3vanmUETSJk4oN8oMW6D0liYLDgNd1JR9XMsBhb2y9zWuJ32V%2BrVyE5ODzfxqeakZnWv2vjptEb8Q%2B7nw5%2Bl2lIEPLngyxj6MiSEt2VYl99qhQgWra2b2HKpa0%3Dâ}],âgroupâ:âcf-nelâ,âmax_ageâ:604800}",ânelâ:"{âsuccess_fractionâ:0,âreport_toâ:âcf-nelâ,âmax_ageâ:604800}",âserverâ:âcloudflareâ,âcf-rayâ:â69ba54416c8741ce-AMSâ},âbufferâ:{âtypeâ:âBufferâ,âdataâ:[60,104,116,109,108,62,13,10,60,104,101,97,100,62,60,116,105,116,108,101,62,52,48,52,32,78,111,116,32,70,111,117,110,100,60,47,116,105,116,108,101,62,60,47,104,101,97,100,62,13,10,60,98,111,100,121,62,13,10,60,99,101,110,116,101,114,62,60,104,49,62,52,48,52,32,78,111,116,32,70,111,117,110,100,60,47,104,49,62,60,47,99,101,110,116,101,114,62,13,10,60,104,114,62,60,99,101,110,116,101,114,62,110,103,105,110,120,47,49,46,49,56,46,48,32,40,85,98,117,110,116,117,41,60,47,99,101,110,116,101,114,62,13,10,60,47,98,111,100,121,62,13,10,60,47,104,116,109,108,62,13,10]},âtextâ:"\r\n404 Not Found\r\n\r\n
I mean, instead of doing:
return Moralis.Cloud.httpRequest({url: âhttps://cr7ge1kve9u7.moralishost.com/â + paddedHex + â.jsonâ})
you should do:
x = âhttps://cr7ge1kve9u7.moralishost.com/â + paddedHex + â.jsonâ
logger.info(x);
return Moralis.Cloud.httpRequest({url: x})
so that you see what url it tries to access there.
yep, it looks like it run ok once from that log
why did it stop again ? I didnt change anything
I donât know, do you also send parameters to that cloud function? maybe only some ids work
how to clear the moralis log?