Skip to content

Can't get 'result' value to propagate in promise chain #23

Description

@RedKnight91

I'm using this module to read a value in a Firebase Realtime DB node for an ongoing login.

Here is a code snippet:

const tryGetAuthStatus = (user) =>
    new Promise((resolve, reject) => {
        var login_node = user.child(provider)

        if (login_node.exists()) {
            resolve(login_node.val().status)
        }
    })

ref.child(uuid).once('value') // Returns a promise
    .then((user) =>
        intervalPromise(
            async (iteration, stop) => await tryGetAuthStatus(user), // Returns a promise
            attempts_pause,
            {iterations: attempts_max, stopOnError: true}
        )
    )
    .then((result) => console.log(result))  // undefined

As you can see I'm returning the interval to continue the promise chain. When firebaseTryGetAuth resolves, it returns the correct result (e.g. "authorized"), but the last 'then' in the chain gets no result from the returned intervalPromise. How can I propagate the result?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions