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

152
Views
Promise Error in node-express, result not getting stored in array

Simply, I want to store results in this array and want this result outside this.data function I want to pass these results as this.data and when I'm importing this function i use this.data

database = admin.database();

class PrivateSingleton {
  constructor() {
    let a = [];
    const keyref = database.ref("data");
    const finalfinaldata = keyref.get().then((data) => {
      const finalData = data.val();
      // console.log(finalData)
      return finalData;
    });

    this.data = finalfinaldata.then(function (result) {
      // console.log(result);
      a.push(result);
    });
    console.log(a);

    this.iv = "IVVV";
    this.key = "aaa";
  }
}

class Singleton {
  constructor() {
    throw new Error("Use Singleton.getInstance()");
  }

  static getInstance() {
    if (!Singleton.instance) {
      Singleton.instance = new PrivateSingleton();
    }
    return Singleton.instance;
  }
}

module.exports = Singleton;

OUTPUT

  : [] // Here I want my result in this array.
about 4 years ago · Juan Pablo Isaza
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!