Skip to content

Instantly share code, notes, and snippets.

@franckweb
Last active December 21, 2022 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franckweb/a981abe204be0ebaca348bf68b1cf71e to your computer and use it in GitHub Desktop.
Save franckweb/a981abe204be0ebaca348bf68b1cf71e to your computer and use it in GitHub Desktop.
Javascript Promise
const myMethod = function () {
const promise = new Promise(function (resolve, reject) {
const result = null;
const y = "geeksforgeeks";
if (result !== null) {
resolve(result);
} else {
reject("Error");
}
});
return promise;
};
async function demo() {
try {
let response = await myMethod();
} catch (error) {
}
}
demo();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment