Could someone help me with this, I am trying to pass the owner wallet address via URL, for example âhttps://wwwâŚcom/page?owner=owneraddressâ and for this I have created a class component that I called User:
import { withRouter } from 'next/router';
import { Component } from 'react';
class ClassComponentExample extends Component {
render() {
const router = this.props.router;
const { owner } = router.query;
return (
<p>{owner}</p>
);
}
}
export default withRouter(ClassComponentExample);
And when, as a test, I call this component in the page it brings me in text form the address sent by the URL:
However, when I use the same component inside the Moralis code to call the API, it gives error as invalid address:
import User from '../components/User';
....
the code I am using for this is(I hid the token address):
export async function getServerSideProps(context) {
await Moralis.start({ apiKey: process.env.MORALIS_API_KEY });
const nftList = await Moralis.EvmApi.account.getNFTsForContract({
address: <User/>,
tokenAddress: '...',
chain: 5
});
return {
props: {
message:
// if user has at least one NFT he will get protected content
nftList.raw.total > 0 ? 'Yes' : "No",
nftList: nftList.raw.result,
},
};
}
export default Protected;
Note: If I create the const called âownerâ and put the wallet address in it and pass it by âaddress:â it works! And by that I mean:
const owner: "walletaddress"
...
const nftList = await Moralis.EvmApi.account.getNFTsForContract({
address: {owner},
tokenAddress: '...',
chain: 5
});
I donât understand why sending the address via URL is not being accepted by Moralis API⌠Could someone help me with this?
Thank you so much! =D