File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 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
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
1624function 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
2642async 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
You can’t perform that action at this time.
0 commit comments