Skip to content

Instantly share code, notes, and snippets.

@monners
Created January 23, 2017 21:55
Show Gist options
  • Save monners/6b85081ae42ed7df1733aeb3f5084da8 to your computer and use it in GitHub Desktop.
Save monners/6b85081ae42ed7df1733aeb3f5084da8 to your computer and use it in GitHub Desktop.
Promise creation example
function ajaxRequest (url, cb) {
setTimeout(() => {
cb({ height: 1000, width: 500});
}, 2000)
}
const p = new Promise((res, rej) => {
ajaxRequest('url', (data) => {
res(data);
})
});
p.then(data => {
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment