Skip to content

Instantly share code, notes, and snippets.

@superjojo140
Last active March 22, 2020 16:48
Show Gist options
  • Save superjojo140/591c7c1a9f7dd09141b2bcc1514366bd to your computer and use it in GitHub Desktop.
Save superjojo140/591c7c1a9f7dd09141b2bcc1514366bd to your computer and use it in GitHub Desktop.
JS returning a promise - Syntax
function myCoolPromise() {
return new Promise(function (resolve, reject) {
//do some async things
const data = "this_is_so_async";
//if successfull
resolve(data);
//if not
reject("error");
});
}
function wait = ms => {
return new Promise(resolve => setTimeout(resolve, ms))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment