import Moralis from âmoralisâ;
export default async function handler(req: any, res: any) {
if (req.method !== âPOSTâ) {
return res.status(405).send({message: âOnly POST request are allowedâ});
}
if (!Moralis.Core.isStarted) {
await Moralis.start({apiKey: process.env.MORALIS_API_KEY})
}
const address = â0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13dâ;
const chain = 97;
try {
const response = await Moralis.EvmApi.token.getWalletTokenBalances({
address,
chain,
});
return res.status(200).json({
data: tokens,
});
} catch (e) {
return res.status(500).send({message: e});
}
}
this is my error, people tell me whatâs wrong.
- error Error [TypeError]: Converting circular structure to JSON
â> starting at object with constructor âClientRequestâ
| property âsocketâ -> object with constructor âTLSSocketâ
â property â_httpMessageâ closes the circle
at JSON.stringify ()
at sendData (E:\projects\revoke\node_modules\next\dist\server\api-utils\node.js:201:47)
at ServerResponse.apiRes.send (E:\projects\revoke\node_modules\next\dist\server\api-utils\node.js:444:31)
at handler (webpack-internal:///(api)/./src/pages/api/moralis/token-wallet.ts:59:32)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
digest: undefined
}