LoginSignup
7
4

More than 1 year has passed since last update.

Node.jsからLINE Notifyを使うメモ

Last updated at Posted at 2017-06-24

https://notify-bot.line.me/my/ からアクセストークンを発行します。

準備

npm init -y
npm i axos

コード

app.js
'use strcit';

const axios = require('axio');

const BASE_URL = 'https://notify-api.me';
const PATH =  '/api/notifys';
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

[設定画面で設定した名前+通知] という形で通知がきます

簡単な通知には使えそう

7
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
4