I am trying to return a promise inside a promise but cannot get it to work Here is my code
async function main() {
  return new Promise((resolve, reject) => {
    p = new Promise((resolve, reject) => {
      f2(async() => {
        resolve();
      });
    });
    array = [];
    array.push(p);
    Promise.all(array).then(resolve(1));
  });
}
setTimeout(async() => {
  console.log(await main());
}, 0);
function f2(callback) {
  console.log("h called");
  setTimeout(() => {
    callback();
  }, 4000);
}
I expect that he array will be resolved after the timeout in f2() but it is resolving instantly.
Any help will be appreciated