// old const getData = callback => { setTimeout(() => { const number = Math.random(); callback(number); }, 5000); } // new const getData = callback => { let promiseReject; const promise = new Promise(reject => promiseReject = reject); setTimeout(() => { const number = Math.random(); promiseReject(number); callback && callback(number); }, 5000); return promise }