node.js - 如何解决 TypeError: Cannot read property 'then' of undefined
问题描述
我似乎无法让我的浏览器正确地使用 Fortmatic 进行身份验证并不断收到 TypeError: Cannot read property 'then' of undefined (我正在使用 nextjs)。
我已经放了一个按钮,以便我可以测试。一直试图弄清楚这一点。谢谢大家
import Head from 'next/head'
import styles from '../styles/Home.module.css'
import Githubcorner from './components/Githubcorner'
import React from 'react'
import Fortmatic from 'fortmatic'
import Web3 from 'web3'
export default function Home() {
React.useEffect(() => {
const fm = new Fortmatic('API_Key');
window.web3 = new Web3(fm.getProvider());
console.log("window.innerHeight", window.innerHeight);
}, []);
const handleGetAccounts = () => {
web3.eth.getAccounts().then(console.log);
}
return (
<div className={styles.container}>
<Head>
<title>Monaliza</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<main className={styles.main}>
<button
onClick={handleGetAccounts}>Random check</button>
<div className={styles.grid}>
<a
href="/Instafeedpage"
className={styles.card}
>
<h3>NFTs on The Gram →</h3>
<p>See some dope minted NFTs on the gram</p>
</a>
<a
href="/Instadroppage"
className={styles.card}
>
<h3>Drop them NFTs →</h3>
<p>Mint your own NFTs</p>
</a>
</div>
</main>
<footer className={styles.footer}>
<a href={"https://github.com"}><img src="/githublogo.png" alt="Github Icon" className={styles.logo} /></a>
<a href={"https://discord.com"}><img src="/discord.svg" alt="Discord Icon" className={styles.logo} /></a>
</footer>
</div>
)
}
解决方案
推荐阅读
- spring-boot - liquibase 临时文件未删除
- python-3.x - 如何为不是函数python3的代码块设置超时
- c++ - c/c++ linting 或格式检查代码文档
- css - 纯CSS多个堆叠位置粘?
- java - 如何等待滚动到页面的元素
- cart - Magento 2 - 估计运费和税金购物车不计算或包括我的自定义运输方式的费率
- android-studio - 更新 Android Studio 后无法 ctrl+B 或 ctrl+click
- sql-server - 如何将varchar的子字符串转换为小数点前的数字并将varchar的子字符串转换为小数点后的数字?
- apache-spark - 是否可以直接将数据从 Nifi 发送到 Spark Structured Streaming/Storm 而不会丢失数据?
- c# - 即使激活了 bbcomm,bloomberg api 也不会从 c# 连接