【问题标题】:web3 in react-native : Cannot read property 'getReader'react-native 中的 web3:无法读取属性“getReader”
【发布时间】:2019-08-26 10:23:00
【问题描述】:

版本

"web3": "^1.2.1" "react-native": "0.59.10"

set-up tutorialhttps://github.com/ethereum/web3.js/issues/1022,我能够在react-native 中安装web3,但是我收到了这个错误:

错误

Possible Unhandled Promise Rejection (id: 1): TypeError: Cannot read property 'getReader' of undefined TypeError: Cannot read property 'getReader' of undefined at new exports.IncomingMessage (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:222317:34) at module.exports.ClientRequest._connect (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:222201:22) at blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:222115:14 at tryCallOne (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:45372:14) at blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:45473:17 at blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46351:21 at _callTimer (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46240:9) at _callImmediatesPass (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46276:9) at Object.callImmediates (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:46495:14) at MessageQueue.__callImmediates (blob:http://localhost:8081/4f48abd1-1bd3-445a-bdbc-3cdeca3a37a2:16572:16)

当我执行诸如web3.eth.getTransactionCountweb3.eth.getBlock('latest') 之类的promise 方法时发生错误。

试试

我试过console.log(web3.version),完全没问题

【问题讨论】:

  • 给我看你正在尝试的代码,而不是你研究的链接。

标签: react-native promise ethereum web3


【解决方案1】:

经过一番深入搜索,我发现使用web3@1.0.0-beta.34react-native 更稳定,因此不再出现提到的问题。问题解决了=)

【讨论】:

    猜你喜欢
    • 2016-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-27
    • 2017-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多