File tree 2 files changed +38
-26
lines changed
2 files changed +38
-26
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const fs = require ( 'fs' ) ;
4
+
5
+ const readTextFile = filename => fs . promises . readFile ( filename , 'utf8' ) ;
6
+
7
+ readTextFile ( 'file1-.txt' )
8
+ . then (
9
+ data => {
10
+ console . dir ( { file1 : data } ) ;
11
+ return readTextFile ( 'file2.txt' ) ;
12
+ } ,
13
+ reason => {
14
+ console . log ( 'Cannot read file1.txt --- A' ) ;
15
+ console . log ( reason ) ;
16
+ }
17
+ )
18
+ . catch (
19
+ reason => {
20
+ console . log ( 'Cannot read file1.txt --- B' ) ;
21
+ console . log ( reason ) ;
22
+ }
23
+ )
24
+ . then ( data => {
25
+ console . dir ( { file2 : data } ) ;
26
+ return readTextFile ( 'file3.txt' ) ;
27
+ } )
28
+ . catch ( reason => {
29
+ console . log ( 'Cannot read file2.txt' ) ;
30
+ console . log ( reason ) ;
31
+ } )
32
+ . then ( data => {
33
+ console . dir ( { file3 : data } ) ;
34
+ } )
35
+ . catch ( reason => {
36
+ console . log ( 'Cannot read file' ) ;
37
+ console . log ( reason ) ;
38
+ } ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments