Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linebot.js do not return Promise #106

Open
h-nasu opened this issue Apr 26, 2018 · 0 comments
Open

linebot.js do not return Promise #106

h-nasu opened this issue Apr 26, 2018 · 0 comments

Comments

@h-nasu
Copy link

h-nasu commented Apr 26, 2018

Gets below error every time doing Line webhook call because processMessage in linebot.js do not return Promise and doing error handling inside....

[ERROR] Error while message processing TypeError: Cannot read property 'catch' of undefined

      apiaiRequest.on('response', (response) => {
          this.processAiResponse(chatId, response, message.replyToken)
              .then(() => this.log('Message sent'))
              .catch((err) => this.logError(err))
        });

Fix
Just check if return value is valid.
app.js

          var result = bot.processMessage(item, res);
          if (result) {
            result.catch(err => console.error(err));
          }

or just delete '.catch(err => console.error(err));'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant