0

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(list => {accts = list})


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)
0

What version of web3 do you use ?

Note that getAccounts() has been implemented only in the betas of 1.0.0. If you're using the version up to 0.20.0 the method does not exists and web3.eth.accounts will only retrieve an plain array.

| improve this answer | |
  • I have tried to install the web3 1.0.0-beta.18 but it have not been installed successfully in my windows 10. Any idea how this might work please? – Salam Khanji Feb 8 '18 at 7:30
0

From the documentation:

var accounts = web3.eth.accounts;
console.log(accounts); // ["0x407d73d8a49eeb85d32cf465507dd71d507100c1"] 

You can use the Promise version only from 1.0

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.