1

I am making read request to my Firebase DB, but it keeps returning Promise <pending> object. I am relatively new to coding, so I appreciate the help :) - I just want to return the value (given by the path) in JSON format.

Here is the code I'm running:

let path7 = database.ref('CheckOuts/2)');

path7.once('value').then(function(elem) {
  let values = elem.val();
  return values;
});
imjared
  • 19,492
  • 4
  • 49
  • 72
David
  • 119
  • 2
  • 1
    Possible duplicate of [How do I return the response from an asynchronous call?](https://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call) – Jack Bashford Apr 03 '19 at 04:09

1 Answers1

0

Try this

let path7 = database.ref('CheckOuts/2)');

let result = await path7.once('value');

const value = snapshot.val();

console.log('result',value);

Make sure that async keyword properly added in the function

shamon shamsudeen
  • 5,466
  • 17
  • 64
  • 129