Skip to content

Commit 2a7beb4

Browse files
authored
Merge pull request #503 from cefn/patch-1
Update no-then.md
2 parents ea48f83 + 8abd830 commit 2a7beb4

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

docs/rules/no-then.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,40 @@ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/asy
1212

1313
👎 Examples of **incorrect** code for this rule:
1414

15+
```js
16+
function countData(url) {
17+
return downloadData(url).then(data => {
18+
return data.length
19+
})
20+
}
21+
```
22+
1523
```js
1624
function getProcessedData(url) {
1725
return downloadData(url).catch(e => {
1826
console.log('Error occurred!', e)
27+
return null;
1928
})
2029
}
2130
```
2231

2332
👍 Examples of **correct** code for this rule:
2433

34+
```js
35+
async function countProcessedData(url) {
36+
const data = await downloadData(url);
37+
return data.length
38+
}
39+
```
40+
2541
```js
2642
async function getProcessedData(url) {
27-
let v
2843
try {
29-
v = await downloadData(url)
44+
return await downloadData(url)
3045
} catch (e) {
31-
console.log('Error occurred!', e)
32-
return
46+
console.log('Error occurred!', e);
47+
return null;
3348
}
34-
return v
3549
}
3650
```
3751

0 commit comments

Comments
 (0)
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