Node.js에서 LINE Notify를 사용하는 메모
준비
npm init -y
npm i --save axios
코드
app.js
'use strcit';
const axios = require('axios');
const qs = require('querystring');
const BASE_URL = 'https://notify-api.line.me';
const PATH = '/api/notify';
const LINE_TOKEN = `アクセストークン`;
let config = {
baseURL: BASE_URL,
url: PATH,
method: 'post',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': `Bearer ${LINE_TOKEN}`
},
data: qs.stringify({
message: `こんばんわ`,
})
};
axios.request(config)
.then((res) => {
console.log(res.status);
})
.catch((error) => {
console.log(error);
});
실행
node app.js
[설정 화면에서 설정한 이름 + 알림] 형태로 알림이 옵니다.
간단한 알림에는 사용할 수 있습니다.
Reference
이 문제에 관하여(Node.js에서 LINE Notify를 사용하는 메모), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/n0bisuke/items/b96ee96314104447a63f텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)