Hi,
I am using Moralis cloud function and job to call the external api but looks like it is not working.
Moralis.Cloud.define("getWalletTokens", async (request) => {
logger.info('pk request', request);
const address = request.param.address;
const tokenResponse = await getAllTokens(address);
logger.info(tokenResponse);
return tokenResponse;
});
function getAllTokens(address) {
logger.info('inside request');
return Moralis.Cloud.httpRequest({
url: `https://deep-index.moralis.io/api/v2/${address}/erc20?chain=bsc`
}).then(function(httpResponse) {
// success
logger.info("PK HTTP==>",httpResponse);
return httpResponse.text;
},function(httpResponse) {
// error
console.error('Request failed with response code ' + httpResponse.status);
});
}
const params = { address: "0xce8b75302ab72fc366b62557cfcbb43f3d438328cf" };
const tokens = await Moralis.Cloud.run("getWalletTokens", params);
I am calling above cloud function from web app. also when I am logging the request parameter I am not seeing the parameter which I am passing from my code. I am getting empty value for request.param.address