Skip to content
Advertisement

Why is this promise returning undefined?

I am trying to write a simple function like this

JavaScript

and I have made a firebase helper like this

JavaScript

however, league is logging out as undefined and in here is logging out second. however, I thought it would be the other way around? I thought it would “await” for this function to resolve then once it’s resolved, it would show me the result. what am I doing wrong?

Advertisement

Answer

do it like this:

JavaScript

you’re currently immediately resolving your outer promise but with an inner promise, and that inner promise doesn’t return anything at all, hence undefined. Just return the promise directly. Cleaner, simpler.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement