Skip to content

Instantly share code, notes, and snippets.

@Gumball12
Created February 8, 2020 02:42
Show Gist options
  • Save Gumball12/763cb2a54f799e92c40a858eb637b016 to your computer and use it in GitHub Desktop.
Save Gumball12/763cb2a54f799e92c40a858eb637b016 to your computer and use it in GitHub Desktop.
naver-papago-example
'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