Skip to content
Advertisement

Get a value from a callback in another function NodeJS

I’m desperately trying to recover the value of a callback function but I have no idea how to do that. I have a function where I execute this code:

JavaScript

Who performs this function:

JavaScript

And which is called by this variable:

JavaScript

I would like my `authentication’ variable to take the value returned in the callback, and I have no idea how to do that. Returning the callback function to my original function doesn’t work.

Advertisement

Answer

You could use a promise, would need to use an async function as well though.

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