NodeJs + NickJs:在asynchronous函数中进行同步调用

我正在使用NickJs来制作WebRequests。 在大多数情况下,NickJs做我所需要的(打开浏览器,导航等)。 不过,我需要在继续执行代码之前对另一个服务进行同步调用(自定义WebRequest)。

我无法弄清楚如何正确地使这个调用同步。 我当前的设置使用包装在asynchronous函数中的NickJs,并使用“await”等待WebRequest返回。

我不认为我可以将这个用于我的自定义请求,但我觉得我应该能够做我自己的function,并等待WebRequest完成,然后继续执行代码。

例:

const nick = new Nick({ printNavigation: false, printResourceErrors: true, printPageErrors: true, resourceTimeout: 10000, userAgent: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36", }) ; (async () => { await tab.open("https://google.com") //custom function here to request another webpage from another service //and wait for the result before moving on to next await call //Continue on as normal with code await tab.open("https://google.com") })() .then(() => { console.log("Hooray!") nick.exit() }) .catch((err) => { console.log(`Boo!: ${err}`) nick.exit(1) })