Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function getData(callback) {
setTimeout(() => callback("hi"), 10);
}
function render(promiseData) {
promiseData.then(data => console.log("data"));
}
// wrapper around getData() to make it return a promise
function getDataPromise() {
return new Promise((resolve, reject) => {
getData(resolve);
});
}
// use render with the wrapper
render(getDataPromise());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.