Skip to content

Commit

Permalink
Merge pull request #503 from cefn/patch-1
Browse files Browse the repository at this point in the history
Update no-then.md
  • Loading branch information
theinterned authored Feb 5, 2024
2 parents ea48f83 + 8abd830 commit 2a7beb4
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions docs/rules/no-then.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
```

Expand Down

0 comments on commit 2a7beb4

Please sign in to comment.