Showing
1 changed file
with
16 additions
and
7 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 | - | 41 | + "Accept": "application/json", |
42 | - rp.post( apiReqOption ) | 42 | + "Content-Type": "application/json", |
43 | - .then( ( body ) => { | 43 | + },uri : URL.ETRI + query, body : JSON.stringify( apiReqJson ) }; |
44 | - body = JSON.parse( body ); | 44 | + |
45 | - resolve( body ); | 45 | + rp.post( apiReqOption ) |
46 | - }) | 46 | + .then( ( body ) => { |
47 | + body = JSON.parse( body ); | ||
48 | + if( body.result == "-1" ) { | ||
49 | + throw new Error( body.reason ); | ||
50 | + } | ||
51 | + resolve( body ); | ||
52 | + }) | ||
53 | + .catch( ( err ) => { | ||
54 | + throw new Error( err ); | ||
55 | + }); | ||
47 | }) | 56 | }) |
48 | } | 57 | } |
49 | 58 | ... | ... |
-
Please register or login to post a comment