Trying to make an AJAX a promise in order to force the app to wait


Junior Member
Nov 13, 2018
Reaction score
I'm trying to use an AJAX in an application using puppeteer.js. In puppeteer everything returns a promise so you can effectively use the await keyword before most actions to force it to wait. This is kind of crucial since I need certain things done in chronological order.

However, let's say I have some vendor code that performs an AJAX request deeply nested inside a function. I want to somehow use that function and force the app to wait for a response before continuing.

I basically want to use await keyword but with a custom function. I almost want the function to inherit from promise because or else I can't use it?
your custom function only needs to return a new promise
but to make it work you need to know when the request is done, a callback or some event?
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock