My function return before executing the previous linse.

aliplutus

aliplutus

Posted on March 8, 2021

My function return before executing the previous linse.

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;
  }
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
aliplutus
aliplutus

Posted on March 8, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related