Firstly, to begin, It does not matter what WebAPI call I use.
import './App.css';
import {useMoralis, useMoralisWeb3Api} from "react-moralis";
function App() {
const { authenticate, isAuthenticated, user } = useMoralis();
const Web3Api = useMoralisWeb3Api();
const fetchBal = async () => {
try {
const result = await Web3Api.account.getNFTs({address: "0x95272629cCa43106a879607DD10b8de1f0E46Ff5", chain: "ropsten"});
console.log(result);
} catch (e) {
console.log(e);
}
}
if (!isAuthenticated) {
return (
<div>
<button onClick={() => authenticate()}>Authenticate</button>
</div>
);
}
return (
<div>
<h1>Welcome {user.get("username")}</h1>
<p>
<button onClick={fetchBal}> test fetchBal</button>
</p>
</div>
);
}
export default App;
Is returning
TypeError: Cannot read properties of undefined (reading 'getNFTs')
at fetchBal (App.js:10)
at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
at invokeGuardedCallback (react-dom.development.js:4056)
at invokeGuardedCallbackAndCatchFirstError (react-dom.development.js:4070)
at executeDispatch (react-dom.development.js:8243)
at processDispatchQueueItemsInOrder (react-dom.development.js:8275)
at processDispatchQueue (react-dom.development.js:8288)
at dispatchEventsForPlugins (react-dom.development.js:8299)
at react-dom.development.js:8508
at batchedEventUpdates$1 (react-dom.development.js:22396)
at batchedEventUpdates (react-dom.development.js:3745)
at dispatchEventForPluginEventSystem (react-dom.development.js:8507)
at attemptToDispatchEvent (react-dom.development.js:6005)
at dispatchEvent (react-dom.development.js:5924)
at unstable_runWithPriority (scheduler.development.js:468)
at runWithPriority$1 (react-dom.development.js:11276)
at discreteUpdates$1 (react-dom.development.js:22413)
at discreteUpdates (react-dom.development.js:3756)
at dispatchDiscreteEvent (react-dom.development.js:5889)