Convert callback-based javascript to ES6 Promises