-3

I have a question??.Why this function return value is undefined. i don't understand.

Help to solve me please.

enter image description here

  • 3
    Post your code as text instead of an image. – Marwelln Jan 13 '18 at 18:20
  • ^^ why: http://meta.stackoverflow.com/q/285551/157247 (We would also need to see more of it, but you're probably looking for this: http://stackoverflow.com/questions/14220321/how-do-i-return-the-response-from-an-asynchronous-call). – T.J. Crowder Jan 13 '18 at 18:20
  • There's not enough code provided to make that determination...at the very least provide the entire function – Dom Jan 13 '18 at 18:21
  • 1
    Welcome to Stackoverflow, please read [How To Ask](https://stackoverflow.com/help/how-to-ask). Pay special attention to [How To Create MCVE](https://stackoverflow.com/help/mcve). Make sure you tag your question with proper labels (programming language, relevant technologies etc). The more effort you'll put into posting a good question: one which is easy to read, understand and which is [on topic](https://stackoverflow.com/help/on-topic) - the chances are higher that it will attract the relevant people and you'll get help even faster. Good luck! – Nir Alfasi Jan 13 '18 at 18:22
  • 2
    A return in a callback does not return to the outer function – charlietfl Jan 13 '18 at 18:22
  • 1
    @charlietfl: Particularly not when the outer function has already returned. :-D – T.J. Crowder Jan 13 '18 at 18:23

1 Answers1

-1

Because you're trying to return from a callback function's scope, which doesn't return to the outer function's scope. This is a pretty common mistake.

You should find another way to write this function so the query functions are in the same scope. Maybe use Promises or async-await?

Amit Beckenstein
  • 1,220
  • 12
  • 20