Would you please help: When I run the below command in my nodejs console I get the below error: (I am using web3 0.20.0) on Windows 10
web3.eth.getAccounts().then(e => console.log(e));
The error was as follow:
TypeError: Cannot read property 'then' of undefined
> TypeError: callback is not a function
at c:\Users\Salam Khanji\Ether\node_modules\web3\lib\web3\property.js:119:13
at c:\Users\Salam Khanji\Ether\node_modules\web3\lib\web3\requestmanager.js:89:9
at XMLHttpRequest.request.onreadystatechange (c:\Users\Salam Khanji\Ether\node_modules\web3\lib\web3\httpprovider.js:119:7)
at XMLHttpRequestEventTarget.dispatchEvent (c:\Users\Salam Khanji\Ether\node_modules\web3\node_modules\xhr2\lib\xhr2.js:64:18)
at XMLHttpRequest._setReadyState (c:\Users\Salam Khanji\Ether\node_modules\web3\node_modules\xhr2\lib\xhr2.js:354:12)
at XMLHttpRequest._onHttpResponseEnd (c:\Users\Salam Khanji\Ether\node_modules\web3\node_modules\xhr2\lib\xhr2.js:509:12)
>
I am guessing their might be one of below issue
geth --rpc --rpccorsdomain "*" --rpcapi eth,net,web3,personal,miner,txpool,debug --datadir ~/Desktop/local-network/
var accounts = web3.eth.accounts;//Will return all the accounts.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.