Closed saarshah closed 4 years ago
I write a command confluxWeb.cfx.getTransactionCount("0xa70ddf9b9750c575db453eea6a041f4c8536785a"); it shows following output
confluxWeb.cfx.getTransactionCount("0xa70ddf9b9750c575db453eea6a041f4c8536785a");
Promise { <pending> , domain: Domain { domain: null, _events: [Object: null prototype] { removeListener: [Function: updateExceptionCapture], newListener: [Function: updateExceptionCapture], error: [Function: debugDomainError] }, _eventsCount: 3, _maxListeners: undefined, members: [], [Symbol(kWeak)]: WeakReference {} } }
when i write above command with await keyword, then following error shows;
SyntaxError: await is only valid in async function
@saarshah , Async () function returns the object is a Promise, so can't use the outermost layers in await get its return value, you should use the original way, then () chain to deal with this Promise。
I write a command
confluxWeb.cfx.getTransactionCount("0xa70ddf9b9750c575db453eea6a041f4c8536785a");
it shows following outputwhen i write above command with await keyword, then following error shows;