From 4c4e50ca88f89e1d1776391a0ebeef76fbaa574d Mon Sep 17 00:00:00 2001 From: oktavianidewi Date: Thu, 29 Aug 2019 12:32:34 +0700 Subject: [PATCH 1/2] Add any --- components/scripts/helper.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/scripts/helper.ts b/components/scripts/helper.ts index ca9e1f9..47989c7 100644 --- a/components/scripts/helper.ts +++ b/components/scripts/helper.ts @@ -213,7 +213,7 @@ export default class Helper extends Component { public difference(object : any, base : any) { function changes(object : any, base : any) { - return _.transform(object, function(result, value, key) { + return _.transform(object, function(result: any, value, key) { if (!_.isEqual(value, base[key])) { result[key] = (_.isObject(value) && _.isObject(base[key])) ? changes(value, base[key]) : value; } From 305f6f458f55552d1ef57fe80f02f9bc79006652 Mon Sep 17 00:00:00 2001 From: oktavianidewi Date: Thu, 29 Aug 2019 12:33:08 +0700 Subject: [PATCH 2/2] Add handler when promise return empty data --- components/bots/bot.ts | 8 ++++++-- lib/components/bots/bot.js | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/components/bots/bot.ts b/components/bots/bot.ts index 30e4dbf..1cf1861 100644 --- a/components/bots/bot.ts +++ b/components/bots/bot.ts @@ -406,8 +406,12 @@ export default class Bot extends Component { let result; promise.then((res: any) => { - done = true; - result = res; + if (res.data !== "") { + done = true; + result = res; + } else { + error = new Error("Error found. Please check your bot."); + } }).catch((e: Error) => { error = e; }); diff --git a/lib/components/bots/bot.js b/lib/components/bots/bot.js index db06213..84e64bd 100644 --- a/lib/components/bots/bot.js +++ b/lib/components/bots/bot.js @@ -394,8 +394,13 @@ class Bot extends merapi_1.Component { let error = null; let result; promise.then((res) => { - done = true; - result = res; + if (res.data !== "") { + done = true; + result = res; + } + else { + error = new Error("Error found. Please check your bot."); + } }).catch((e) => { error = e; });