Return Object from JS Promise

I’m using Firebase Web, and am trying to get both a Firestore (database) query and a Storage query (from a field in the Firestore document).

This is currently what I’m working with:

let product = products.where('productID', '==', query).get()
        .then(querySnapshot => {
            querySnapshot.forEach(doc => {
                return {
        .catch(e => {


The problem is that I need the product to be an object outside the promise and don’t know how to achieve that.

JS Console Log:

Promise {}
[[PromiseStatus]]: “resolved”
[[PromiseValue]]: undefined

Thanks for the help :slight_smile:

Short answer is you can’t: once you have a Promise, you can’t work with normal return values anymore, all you’ll ever have from then on is Promises. When you receive the product value, handle it inside the .then clause by passing it to a function that does whatever you need to do with the product.

I suggest learning async/await from ES7: they make working with promises much nicer, and they do let you just return values “normally” from an async function – though anyone consuming that value will still have to await it and thus also be an async function.

Thanks, will pass to another function :+1:. Will look into async/await also…