await callback 1

await callback

function apiOn(event) {
  return new Promise(resolve => {
    api.on(event, response => resolve(response));
  });
}

Here is what the above code is Doing:
1. We’re importing the `api` object from the `api.js` file.
2. We’re creating a function called `apiOn` that takes an event as a parameter.
3. We’re returning a new Promise that resolves with the response from the `api.on` function.

Now, let’s use this function to listen for the `ready` event.

Similar Posts