Why I got error when tried
.Cloud is undefine, why ?
Someone got same error ?
What are you trying to do there?
For that error it says that Moralis.Cloud is undefined.
I tried to call requesMessage function from cloud
I using Nextjs for client.
Try call cloud function from /api in Nextjs
My api/api.js
import Moralis from 'moralis';
import {EvmChain} from '@moralisweb3/evm-utils';
await Moralis.start({
apiKey: process.env.NEXT_PUBLIC_MORALIS_STREAM_API_KEY,
});
try {
const {message} = await Moralis.Cloud.run('requestMessage', {
address: address,
chain: EvmChain.ETHEREUM,
network: 'evm',
});
} catch (e) {
console.log('error111111', Moralis.Cloud);
console.error(e);
}
wrong syntax ?
You can get with Moralis v1 sdk and you will need the server url and app id
Can you clear details code ?
I confuse syntax v1 and v2
As you know, I tried with v1 docs but not success
Moralis.Cloud undefined
This is not the syntax for Moralis v1 sdk. In Moralis v1 sdk you have to provide a server url and an app id for Moralis.start
Hi Cryptokid,
I changed
and get error
did you install moralis v1 sdk before doing that?
yes bro,
V1 before and self-host to v2
Now, how can call cloud functions with v1 or v2 ?
you have to install moralis sdk v1 first and then you can use it
I have v1 and v2
Why could not use:
const {message} = await Moralis.Cloud.run('requestMessage', {
address: account,
chain: parseInt(chainId, 16),
network: 'evm',
});
you may need two environments, one with moralis v1 sdk and one with moralis v2 sdk, or you can try to install parse server SDK
somehow you will have to use moralis v1 SDK for Moralis.Cloud syntax
this is an example of code that was working with moralis v1 SDK:
x = async () => {
const Moralis = require('moralis/node')
console.log(Moralis.CoreManager.get("VERSION"))
await Moralis.start({ serverUrl: "https://213213:2053/server", appId: "4124124" });
const options = {
chain: "eth",
trasaction_hash: "0x188232a3639f5a10ff097178519cb017f49bb3430fba10b29b21eb8e343b98f7",
};
const transaction = await Moralis.Web3API.native.getTransaction(options);
console.log(transaction);
}
x();