Created
February 8, 2020 02:42
-
-
Save Gumball12/763cb2a54f799e92c40a858eb637b016 to your computer and use it in GitHub Desktop.
naver-papago-example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const axios = require('axios'); | |
module.exports.papago = async ({ body }) => { | |
const { text } = JSON.parse(body); | |
console.log(text); | |
const { data } = await axios.post('https://openapi.naver.com/v1/papago/n2mt', { // data | |
source: 'ko', | |
target: 'en', | |
text: '만나서 반갑습니다.', | |
}, { | |
headers: { | |
'Content-Type': 'application/json', // 'application/json' 형태로 전송해야만 함 | |
'X-Naver-Client-Id': '---', | |
'X-Naver-Client-Secret': '---', | |
}, | |
}) | |
.catch(err => console.log(err.response.data)); | |
console.log(data); | |
return { | |
statusCode: 200, | |
body: 'test', | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment