Showing
1 changed file
with
18 additions
and
0 deletions
| ... | @@ -46,4 +46,22 @@ apiRequest.ETRI = async ( query, argument ) => { | ... | @@ -46,4 +46,22 @@ apiRequest.ETRI = async ( query, argument ) => { |
| 46 | }) | 46 | }) |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | +/** | ||
| 50 | + * @param {String} text 고치고 싶은 문장 | ||
| 51 | + * @returns {Object} 정해진 형식의 응답을 보내줍니다. | ||
| 52 | + * @description 네이버 맞춤법 사이트로 text를 보내서 응답을 받아옵니다. | ||
| 53 | +*/ | ||
| 54 | +apiRequest.Korean = async ( text ) => { | ||
| 55 | + return new Promise( ( resolve,reject ) => { | ||
| 56 | + rp( { "uri" : URL.Korean+encodeURI( text ) } ) | ||
| 57 | + .then( ( body ) => { | ||
| 58 | + body = body.substring( 1, body.length - 2 ); | ||
| 59 | + resolve( JSON.parse( body ).message.result ); | ||
| 60 | + }) | ||
| 61 | + .catch( ( err ) => { | ||
| 62 | + throw new Error( err ); | ||
| 63 | + }); | ||
| 64 | + }); | ||
| 65 | +} | ||
| 66 | + | ||
| 49 | module.exports = apiRequest; | 67 | module.exports = apiRequest; | ... | ... |
-
Please register or login to post a comment