File tree 1 file changed +19
-5
lines changed
1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -12,26 +12,40 @@ https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/asy
12
12
13
13
👎 Examples of ** incorrect** code for this rule:
14
14
15
+ ``` js
16
+ function countData (url ) {
17
+ return downloadData (url).then (data => {
18
+ return data .length
19
+ })
20
+ }
21
+ ```
22
+
15
23
``` js
16
24
function getProcessedData (url ) {
17
25
return downloadData (url).catch (e => {
18
26
console .log (' Error occurred!' , e)
27
+ return null ;
19
28
})
20
29
}
21
30
```
22
31
23
32
👍 Examples of ** correct** code for this rule:
24
33
34
+ ``` js
35
+ async function countProcessedData (url ) {
36
+ const data = await downloadData (url);
37
+ return data .length
38
+ }
39
+ ```
40
+
25
41
``` js
26
42
async function getProcessedData (url ) {
27
- let v
28
43
try {
29
- v = await downloadData (url)
44
+ return await downloadData (url)
30
45
} catch (e) {
31
- console .log (' Error occurred!' , e)
32
- return
46
+ console .log (' Error occurred!' , e);
47
+ return null ;
33
48
}
34
- return v
35
49
}
36
50
```
37
51
You can’t perform that action at this time.
0 commit comments