Showing
1 changed file
with
10 additions
and
1 deletions
... | @@ -37,13 +37,22 @@ apiRequest.ETRI = async ( query, argument ) => { | ... | @@ -37,13 +37,22 @@ apiRequest.ETRI = async ( query, argument ) => { |
37 | return new Promise( ( resolve, reject ) => { | 37 | return new Promise( ( resolve, reject ) => { |
38 | let apiReqJson = apiRequestJsonFrame; | 38 | let apiReqJson = apiRequestJsonFrame; |
39 | apiReqJson.argument = argument; | 39 | apiReqJson.argument = argument; |
40 | - let apiReqOption = { uri : URL.ETRI + query, body : JSON.stringify( apiReqJson ) }; | 40 | + let apiReqOption = { headers: { |
41 | + "Accept": "application/json", | ||
42 | + "Content-Type": "application/json", | ||
43 | + },uri : URL.ETRI + query, body : JSON.stringify( apiReqJson ) }; | ||
41 | 44 | ||
42 | rp.post( apiReqOption ) | 45 | rp.post( apiReqOption ) |
43 | .then( ( body ) => { | 46 | .then( ( body ) => { |
44 | body = JSON.parse( body ); | 47 | body = JSON.parse( body ); |
48 | + if( body.result == "-1" ) { | ||
49 | + throw new Error( body.reason ); | ||
50 | + } | ||
45 | resolve( body ); | 51 | resolve( body ); |
46 | }) | 52 | }) |
53 | + .catch( ( err ) => { | ||
54 | + throw new Error( err ); | ||
55 | + }); | ||
47 | }) | 56 | }) |
48 | } | 57 | } |
49 | 58 | ... | ... |
-
Please register or login to post a comment