我正在使用带有标志的Geth节点
geth --networkid'49'--datadir'E:你'--rpc --rpcapi'web3,net,personal,admin,eth'--rpccorsdomain'*'console
我正在尝试使用Web3.js获取帐户。每当我尝试使用..请求帐户时..
web3.eth.accounts [0]
要么
web3.eth.getAccounts(accounts => console.log(accounts));
我得到一个错误,因此当打印整个Web3响应时,那里没有任何帐户,它显示以下错误..
[例外:错误:连接错误:无法连接到节点http://localhost:8545。在位于Eth.remoteFunction(:2:14)的Eth.get [as accounts](http://127.0.0.1:8080/node_modules/web3/dist/web3.js:3137:16)的RequestManager.send(http://127.0.0.1:8080/node_modules/web3/dist/web3.js:4350:18)的HttpProvider.send(http://127.0.0.1:8080/node_modules/web3/dist/web3.js:6357:32)的Object.InvalidConnection(http://127.0.0.1:8080/node_modules/web3/dist/web3.js:6260:62)中
当我尝试我的index.html页面没有HTTP-SERVER运行错误是
无法加载http://localhost:8545/:对预检请求的响应未通过访问控制检查:响应中的“Access-Control-Allow-Credentials”标头的值为'',当请求的凭据模式为'时,该值必须为'true'包括'。因此不允许原点'null'访问。 XMLHttpRequest发起的请求的凭据模式由withCredentials属性控制。 HttpProvider.send @ web3.js:4348
未捕获错误:连接错误:无法连接到节点http://localhost:8545。在Object.InvalidConnection(web3.js:3137)的HttpProvider.send(web3.js:4350),在RequestManager.send(web3.js:6357)的Eth.get [as accounts](web3.js:6260)at index html的:50
我不知道问题出在哪里..是否有任何问题与geth节点中的标志或Js中的某些方法有关?谢谢