wiki/content/20201111095230-producing_promises.md

24 lines
450 B
Markdown
Raw Permalink Normal View History

2024-05-06 20:40:05 +00:00
---
2024-10-30 17:34:11 +00:00
date: 2020-11-11
2024-05-06 20:40:05 +00:00
id: e059aba7-2912-4a54-8c04-dbb6fbd3d0a7
title: Producing Promises
---
# Advice
Use [Async functions](20201026103714-javascript_async_functions) instead
of this.
# Syntax
``` javascript
const p = new Promise(
function (resolve, reject) { // (A)
if (true /* replace true with your own logic */) {
resolve(value); // success
} else {
reject(reason); // failure
}
});
```