javascript - 将字符串从 javascript 中的变量添加到 HTML 中的 API URL
问题描述
所以我试图将来自 MetaMask 的以太坊地址包含到 Opensea API 中。
用户钱包地址保存在 userWalletAddress
async function LoginWithMetaMask () {
const accounts = await window.ethereum.request({ method:
'eth_requestAccounts' })
.catch((e) => {
console.error(e.message)
return
})
if (!accounts) { return }
window.userWalletAddress = accounts[0]
userWallet.innerText = window.userWalletAddress
loginButton.innerText = 'Sign out of MetaMask'
我现在想将地址添加到显示/嵌入来自 OpenSea 的 API 的用户 NFT 的 URL。我该怎么做呢?我希望 URL 中的“userWallet”是存储在 window.userWalletAddress 中的地址
<iframe src='https://opensea.io/userWalletAddress?embed=true'
width='50%'
height='50%'
frameborder='0'
allowfullscreen></iframe>
解决方案
推荐阅读
- python - 如何根据python中的数组值更改cmap
- sql - 对客户端列表进行排序的 SQL 查询
- javascript - 在 react.js 中自定义对象的参数
- asp.net - Azure 中的“/”应用程序中的服务器错误(错误:26 - 错误定位指定的服务器/实例)
- javascript - 我如何在 Python 中使用 datetime 或 time 函数进行幸运抽奖?
- node.js - Stripe js:未完成支付,未定义支付
- linux - 保存从文件读取的字节数
- regex - url中的mod重写路径
- javascript - 只有在全部失败时才链接异步回退并打印它们的错误
- c# - 如何打破 C# 中的内部嵌套 Parallel.Foreach 循环?