Conflux-Chain / ConfluxWeb

Conflux JavaScript API, under active development
GNU Lesser General Public License v3.0
7 stars 5 forks source link

ConfluxWeb.cfx.getTransactionCount showing "Pending" #3

Closed saarshah closed 4 years ago

saarshah commented 4 years ago

I write a command confluxWeb.cfx.getTransactionCount("0xa70ddf9b9750c575db453eea6a041f4c8536785a"); it shows following output

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

liuis commented 4 years ago

@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。