first off, i see allot of this question, and then it’s resolved but i can’t find a answer anywhere… So.i did the first part and still get the
code: ‘C0005’,
details: undefined,
[cause]: undefined
error… the code i try is the first call of the video…/** @format */
const express = require('express');
const Moralis = require('moralis').default;
const ethereumUtil = require('ethereumjs-util');
const app = express();
const cors = require('cors');
require('dotenv').config();
const port = 3001;
app.use(cors());
app.use(express.json());
function isValidAddress(address) {
return ethereumUtil.isValidAddress(address);
}
app.get('/tokenPrice', async (req, res) => {
const { query } = req;
if (!isValidAddress(query.addressOne) || !isValidAddress(query.addressTwo)) {
return res.status(400).json({ error: 'Invalid Ethereum address' });
}
try {
const responseOne = await Moralis.EvmApi.token.getTokenPrice({
address: query.addressOne,
});
const responseTwo = await Moralis.EvmApi.token.getTokenPrice({
address: query.addressTwo,
});
console.log(responseOne.raw);
console.log(responseTwo.raw);
return res.status(200).json({});
} catch (error) {
console.error('Moralis SDK Error:', error);
return res.status(500).json({ error: 'Internal server error' });
}
});
Moralis.start({
apiKey: process.env.MORALIS_KEY,
}).then(() => {
app.listen(port, () => {
console.log(`Listening for API Calls`);
});
});
I can’t see the solution anywhere