Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

69
Views
En espera de recibir una advertencia mientras está en el bloque de intento y captura

La primera await a continuación genera la advertencia 'await' has no effect on the type of this expression si no incluyo la línea .catch que se encuentra inmediatamente después (y actualmente comentada). Sin embargo, todo el código está incluido en un bloque try-catch. ¿Por qué recibo esta advertencia? ¿No es MongoClient.connect una llamada asíncrona?

 const db = null async function dbConnect() { try { const client = await MongoClient.connect(url, {useUnifiedTopology: true}) // .catch(err => { console.log(err) }) if (!client) throw new Error("Database Not Available") db = await client.db(dbName) } catch (err) { console.log(err) } } dbConnect()
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

.connect() devuelve una promesa, no un cliente. Prueba este código:

 const db = null async function dbConnect() { try { const client = new MongoClient(url) await client.connect({useUnifiedTopology: true}) db = await client.db(dbName) } catch (err) { console.log(err) } } dbConnect()
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!