File tree Expand file tree Collapse file tree 1 file changed +27
-17
lines changed Expand file tree Collapse file tree 1 file changed +27
-17
lines changed Original file line number Diff line number Diff line change @@ -99,28 +99,38 @@ export default function DataService() {
9999 ////////////////////////////////////////////////////////////
100100 function loadData ( ) {
101101 return new Promise ( ( res , rej ) => {
102- ( user === null
103- ? rej ( )
104- : requestGetData ( ) )
105- . then ( ( d ) => {
106- let data = tryParce ( d ) //here we parce json
107- //console.log("[DATA] from loadData(): ", data)
108- res ( data || [ ] )
109- } , rej )
110- . catch ( rej )
102+ try {
103+ ( user === null
104+ ? Promise . reject ( rej ( ) )
105+ : requestGetData ( ) )
106+ . then ( ( d ) => {
107+ let data = tryParce ( d ) //here we parce json
108+ //console.log("[DATA] from loadData(): ", data)
109+ res ( data || [ ] )
110+ } , rej )
111+ . catch ( rej )
112+ } catch ( e ) {
113+ rej ( e )
114+ console . error ( e )
115+ }
111116 } )
112117 }
113118
114119 function postData ( data ) {
115120 return new Promise ( ( res , rej ) => {
116- ( user === null
117- ? rej ( )
118- : loadData ( ) )
119- . then ( ( d ) => {
120- let pDat = data === null ? ( d || [ ] ) : data
121- requestPostData ( pDat ) . then ( res , rej )
122- } , rej )
123- . catch ( rej )
121+ try {
122+ ( user === null
123+ ? Promise . reject ( rej ( ) )
124+ : loadData ( ) )
125+ . then ( ( d ) => {
126+ let pDat = data === null ? ( d || [ ] ) : data
127+ requestPostData ( pDat ) . then ( res , rej )
128+ } , rej )
129+ . catch ( rej )
130+ } catch ( e ) {
131+ rej ( e )
132+ console . error ( e )
133+ }
124134 } )
125135 }
126136 ////////////////////////////////////////////////////////////
You can’t perform that action at this time.
0 commit comments