Saturday 30 December 2017

How do I wait for the results of a function to later use?

Im a bit of a noob it javascript and node, so sorry for the simple question.I have a varable I need to use but its value comes from a function that i getting data via an API. var myVar = getVarValue(); console.log('This doesnt print myVar' + myVar); function getVarValue (){ myvarout = getapi stuff(); console.log('This prints myVar' + myvarout); return myvarout; } So i need getVarValue to finish. How do I get the result of the function after getVarValue is done?

Submitted December 31, 2017 at 04:43AM by wobmonsta

No comments:

Post a Comment