javascript - 为什么我会收到“未捕获的语法错误:意外的保留字”?
问题描述
我正在使用 metamask ethereum API 创建一个网站。但由于某种原因,我在第 8 行收到此错误:
const provider = await detectEthereumProvider();
问题是我直接从 API 网站复制了这段代码,所以我不知道它为什么会收到错误
https://docs.metamask.io/ guide/ethereum-provider.html#using-the-provider
有人可以帮忙吗?谢谢
解决方案
await关键字必须在异步函数中调用:
async function main()
{
// Place your code here.
}
// Then, call that async function that wraps your code:
main();
推荐阅读
- python - 通过 SQL Server 代理作业在 Conda 中使用 Numpy 运行 python 脚本
- sql - 来自 SQL 源的 BIT 列由数据收集器转换为布尔值
- css - Material-UI Grid - 自动堆叠项目以占用最小垂直空间
- pandas - Pandas - 在不复制数据的情况下计算行数
- css - 2021 年 CSS 动画最佳实践是什么,以确保与所有浏览器兼容?
- swift - iOS 14 TableViewCell 无法设置选定的背景颜色
- arrays - 无法访问 Julia 数组(BoundsError:尝试访问索引 [1] 处的 0 元素 Vector{Int64})
- php - 通过不处理存在数据透视表的查询来排序 laravel 8
- php - 在查询中获取 ACF 后元值
- android - 如何在 Android Studio 的 AlerdDialog 中显示 DatePicker