diff --git a/docs/rules/no-then.md b/docs/rules/no-then.md index 1d377230..3937bbf9 100644 --- a/docs/rules/no-then.md +++ b/docs/rules/no-then.md @@ -12,26 +12,40 @@ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/asy 👎 Examples of **incorrect** code for this rule: +```js +function countData(url) { + return downloadData(url).then(data => { + return data.length + }) +} +``` + ```js function getProcessedData(url) { return downloadData(url).catch(e => { console.log('Error occurred!', e) + return null; }) } ``` 👍 Examples of **correct** code for this rule: +```js +async function countProcessedData(url) { + const data = await downloadData(url); + return data.length +} +``` + ```js async function getProcessedData(url) { - let v try { - v = await downloadData(url) + return await downloadData(url) } catch (e) { - console.log('Error occurred!', e) - return + console.log('Error occurred!', e); + return null; } - return v } ``` pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy