I was following a tutorial on Moralis about building a web3 version of PayPal (https://youtu.be/IwfIxAJiNiw). And I run into this error when trying to get the user balance.
I run into this error before when getting the name of the user but it went away after retrying the same request. So I think it could be an issue on Moralis’ side.
Here is where I think the error is coming from:
app.get("/getNameAndBalance", async (req, res) => {
const { userAddress } = req.query;
const response = await Moralis.EvmApi.utils.runContractFunction({
chain: "0x13881",
address: "0x0dc3eeb267e3fB875c49a2D137779f4574855d01",
functionName: "getName",
abi: ABI,
params: { _user: userAddress },
});
const jsonResponseName = response.raw;
const secondResponse = await Moralis.EvmApi.balance.getNativeBalance({
chain: "0x13881",
address: userAddress,
});
const jsonResponseBal = (secondResponse.raw.balance / 1e18).toFixed(2);
const thirdResponse = await Moralis.EvmApi.token.getTokenPrice({
address: "0x7D1AfA7B718fb89edB30A3aBc0Cfc608AaCfeBB0",
});
const jsonResponseDollars = (
thirdResponse.raw.usdPrice * jsonResponseBal
).toFixed(2);
const jsonResponse = {
name: jsonResponseName,
balance: jsonResponseBal,
dollars: jsonResponseDollarsm,
};
return res.status(200).json({ jsonResponse });
});
Here is the error:
/Users/fiat/Developer/learn-solidity/payPalStarter/backend/node_modules/@moralisweb3/common-core/lib/cjs/index.cjs:1217
return new CoreError({
^
MoralisError [Moralis SDK Core Error]: [C0006] Request failed: timeout of 20000ms exceeded
at RequestController.makeError (/Users/fiat/Developer/learn-solidity/payPalStarter/backend/node_modules/@moralisweb3/common-core/lib/cjs/index.cjs:1217:16)
at RequestController.<anonymous> (/Users/fiat/Developer/learn-solidity/payPalStarter/backend/node_modules/@moralisweb3/common-core/lib/cjs/index.cjs:1187:38)
at step (/Users/fiat/Developer/learn-solidity/payPalStarter/backend/node_modules/@moralisweb3/common-core/lib/cjs/index.cjs:81:23)
at Object.throw (/Users/fiat/Developer/learn-solidity/payPalStarter/backend/node_modules/@moralisweb3/common-core/lib/cjs/index.cjs:62:53)
at rejected (/Users/fiat/Developer/learn-solidity/payPalStarter/backend/node_modules/@moralisweb3/common-core/lib/cjs/index.cjs:53:65) {
isMoralisError: true,
code: 'C0006',
details: undefined,
[cause]: AxiosError: timeout of 20000ms exceeded
at RedirectableRequest.handleRequestTimeout (/Users/fiat/Developer/learn-solidity/payPalStarter/backend/node_modules/axios/dist/node/axios.cjs:3010:16)
at RedirectableRequest.emit (node:events:513:28)
at Timeout.<anonymous> (/Users/fiat/Developer/learn-solidity/payPalStarter/backend/node_modules/follow-redirects/index.js:169:12)
at listOnTimeout (node:internal/timers:564:17)
at process.processTimers (node:internal/timers:507:7)
Any help is appreciated.