javascript - JS Function executing too fast -


i'm doing json call this:

var desc = getitemdescriptions(xxx);  function getitemdescriptions(xxx) { var url = "xxx; var info = {};  request({ url: url, json: true }, function (error, response, body) {      if (!error && response.statuscode === 200) {         info ["..."] = body.result[xxx].yyy;         info ["..."] = body.result[xxx].yyy;         info ["..."] = body.result[xxx].yyy;         info ["..."] = body.result[xxx].yyy;         info ["..."] = body.result[xxx].yyy;     } }) return info; } 

my problem is, json request need time response back... , function doesn't wait response. function returns empty array without waiting.

how can wait response , return filled array?

thx

its not executing fast, way javascript runs statement after statement. data need in success callback function, data available when server response comes asynchronous call time response comes javascript executes next statements.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -