The following function return x before assigning it to res, despite I assign it in an earlier line then the return.
function newData() {
var x: [] | any = [];
lookup("GET", "api/post/", (res: myArrays["posts"], status: number) => {
x = res;
});
console.log(x);
return x;
}
Top comments (0)