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

184
Views
¿Cómo devuelvo los datos del depósito S3 en el nodo?

Me gustaría que main() devuelva los datos en lugar de solo registrarlos en la consola como se muestra a continuación. ¿Cómo lo hago?

 async function main() { // Load the AWS SDK for Node.js var AWS = require("aws-sdk"); // Set the region AWS.config.update({ region: "REGION" }); // Create S3 service object s3 = new AWS.S3({ apiVersion: "2006-03-01" }); // Call S3 to list the buckets s3.listBuckets(function (err, data) { if (err) { console.log("Error", err); } else { console.log(data); } }); } main();
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Intente esperar la función listBuckets .

Cambio

 s3.listBuckets(function (err, data) { if (err) { console.log("Error", err); } else { console.log(data); } });

a

 return await s3.listBuckets();

Si eso no funciona, siempre puede construir una Promise manual y resolverla con los datos.

 async function main() { // Load the AWS SDK for Node.js var AWS = require("aws-sdk"); // Set the region AWS.config.update({ region: "REGION" }); // Create S3 service object s3 = new AWS.S3({ apiVersion: "2006-03-01" }); return await new Promise((resolve, reject) => { // Call S3 to list the buckets s3.listBuckets(function (err, data) { if (err) { reject(err); } else { resolve(data); } }); }); } main();
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!