Why is getAccounts() now asynchronous?
See original GitHub issueThe changes from #436 were only just released in 0.3.1-alpha so I’m just learning about the breaking changes now even though the commit that changed it was from back in October of last year.
Can you explain why getAccounts()
is now asynchronous? This has proved to be quite annoying to migrate. Also, as noted in #548 and #544 there are still numerous cases that benefit from or even require a synchronous method of accessing this information.
If the reason is that the ADAL migration takes too long to perform on the main thread, please know that some users (hey, it me!) are not migrating from ADAL.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Async Problem With getAccounts() : r/ethdev - Reddit
Adding async means getCurrentAccount() returns a Promise. So this part too needs to be inside an async, or deal with the returned promise....
Read more >Async with getAccounts - web3js - Ethereum Stack Exchange
getAccounts() returns an array async function getCurrentAccount(){ const currentAccounts = await web3.eth.
Read more >Why web3.eth.getAccounts().then(console.log) return empty ...
You now need to request permission from the user to get their accounts. So instead of getAccounts() , use requestAccounts() : web3.eth.
Read more >What is the best way to fix this code? - Moralis Web3 Forum
Thanks ivan! I got the code fixed, i had extra IF statement in a function, the running code is now: export const loadAccount...
Read more >web3-eth.Eth.getAccounts JavaScript and Node.js ... - Tabnine
async onClick() { try { //Grab all the accounts from metamask const accounts = await web3.eth.getAccounts(); this.setState({ message: "Choosing a winner.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@joshfriend - Thanks for the suggestions! Very much appreciated. I’m going to publish a TODOs as you suggest shortly and look forward to your feedback. Thanks again!
We introduced synchronous (blocking) APIs in MSAL v1.0.0 (needs to be running on a background thread) - This includes getAccounts(), getAccount(), removeAccount() and acquireTokenSilent()