callback, promises and async await code example
Example: await callback
function apiOn(event) {
return new Promise(resolve => {
api.on(event, response => resolve(response));
});
}
function apiOn(event) {
return new Promise(resolve => {
api.on(event, response => resolve(response));
});
}