From 28e2355b63a1d746b54351ff9de2520bdb886aab Mon Sep 17 00:00:00 2001 From: okhiroyuki Date: Sun, 8 Mar 2020 13:06:32 +0900 Subject: [PATCH 1/2] modify output --- nodes/line-notify.js | 14 +++++----- nodes/locales/en-US/line-nofify.html | 7 ++++- nodes/locales/ja/line-notify.html | 5 ++++ test/line-notify_spec.js | 39 +++++++++++++++++++++------- 4 files changed, 49 insertions(+), 16 deletions(-) diff --git a/nodes/line-notify.js b/nodes/line-notify.js index 8759e03..9879c14 100644 --- a/nodes/line-notify.js +++ b/nodes/line-notify.js @@ -52,7 +52,7 @@ module.exports = function(RED) { node.on('input', function(msg) { if(!node.accessToken){ - sendError(node, "toeken is empty"); + sendError(node, "token is empty"); return; } let datajson = { @@ -130,19 +130,21 @@ module.exports = function(RED) { }; axios.request(lineconfig).then((res) => { - msg.payload = res.data; + msg.status = res.data.status; node.send(msg); node.status({fill: "blue", shape: "dot", text: "success"}); }) .catch((error) => { - sendError(node, error.message); + msg.status = error.response.data.status; + msg.payload = error.response.data.message; + sendError(node, msg); }); }); } - function sendError(node, message){ - node.error(message); - node.status({ fill: "red", shape: "ring", text: message}); + function sendError(node, msg){ + node.error(msg); + node.status({ fill: "red", shape: "ring", text: msg.payload}); } function linetoken(n){ diff --git a/nodes/locales/en-US/line-nofify.html b/nodes/locales/en-US/line-nofify.html index dfa0133..049cce5 100644 --- a/nodes/locales/en-US/line-nofify.html +++ b/nodes/locales/en-US/line-nofify.html @@ -1,6 +1,6 @@