Can I use multiple Moralis calls like that?
For example:
- I want to get data by using Moralis-v1/node with SSR in NextJS, then send it to the component,
- which must be able to use sign-in logic that comes with Moralis-v1 only
Code below has two different import of Moralis object with different names.
I try this but real code is complicated than that, so in order to reduce the errors I needed to ask.
import { useMoralis } from "react-moralis"
import MoralisNode from "moralis-v1/node"
import Moralis from "moralis-v1"
const Page = ({ thisItem }) => {
const { authenticate, enableWeb3 } = useMoralis()
const [authError, setAuthError] = useState(null)
const [isAuthenticating, setIsAuthenticating] = useState(false)
const handleAuth = async (provider) => {
try {
setAuthError(null)
setIsAuthenticating(true)
// Enable web3 to get user address and chain
await enableWeb3({ throwOnError: true, provider })
//...
}
//...
}
// SSR Props
export async function getServerSideProps({ params }) {
const { itemSlug } = params
await MoralisNode.start({
serverUrl: process.env.SERVER_URL,
appId: process.env.APP_ID,
})
// get item by its slug
const item = await MoralisNode.Cloud.run("getItem", {
slug: itemSlug,
})
return {
props: {
thisItem: item,
},
}
}