Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
RedKnight91 opened this issue Nov 19, 2019 · 0 comments
Open

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

RedKnight91 opened this issue Nov 19, 2019 · 0 comments
Labels

Comments

@RedKnight91
Copy link

RedKnight91 commented Nov 19, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants