Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

183
Visualizações
Transpile async/await function from NodeJS to browser side vis Browserify

I have a .js code that is a NodeJS code and is wrote for back-end. But, I want to transpile it to client side. I use Browserify for this purpose. It worked and works until I faced to an error when I browserified the .js file by an async/await function. There is an async/await function in back-end JavaScript that should fetch a file. The async function is:

async function accountHistory(address){
      web3.eth.getBlockNumber().then(function(blockNumber){
           const timeLine=await fetch(<file>);
         });
       } 

This causes this error in browserifying:

SyntaxError: Unexpected token (102:57) while parsing E:\Crypto-Wallet-Demo\New-Wallet.js while parsing file: E:\Crypto-Wallet-Demo\New-Wallet.js
    at DestroyableTransform.end [as _flush] (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\insert-module-globals\index.js:114:21)
    at DestroyableTransform.prefinish (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_transform.js:138:10)
    at DestroyableTransform.emit (node:events:390:28)
    at prefinish (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:619:14)
    at finishMaybe (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:627:5)
    at endWritable (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:638:3)
    at DestroyableTransform.Writable.end (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_writable.js:594:41)
    at DestroyableTransform.onend (C:\Users\lenovo\AppData\Roaming\npm\node_modules\browserify\node_modules\readable-stream\lib\_stream_readable.js:577:10)
    at Object.onceWrapper (node:events:509:28)
    at DestroyableTransform.emit (node:events:402:35)

Whenever I erase the async and await keywords from the code, browserifying is successfull but fetching is incomplete.

What is the problem? What should I do? How can I browserify an async/await function by Browserify?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda