This work fine:
var test = myFunc(2); // 4
function myFunc(id){
return id*2
}
But this code doesn't work:
var test = myFunc(2); // {}
function myFunc(id) {
return myService.getById(id).then(function (result) {
console.log(result[0].name); // John
return result[0].name;
});
}
Could you help me to fix my second example, please?