Skip to content

linebot.js do not return Promise #106

@h-nasu

Description

@h-nasu

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));'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions