This question has already been answered:
How to return the value of data.reponse [0] .uid from the test function?
function test(targetUid){ VK.api("users.get", {uids:shortName,fields:"photo_50"}, function(data) { return data.response[0].uid; }); } var nick = "123123"; console.log(test(nick));