Saturday, 10 June 2017

Nodejs Function is not a function?

I am coding a small chatbot with facebook messenger.

I created 2 main js file: facebook.js and control.js

facebook.js will perform send message/ receive message. control.js will perform some minor logic/ application function.

Let me give a example code for these two js.

In facebook.js

function sendMessage(){
  ///configuring and json format
  //send to facebook server(webhook) by using Bluebird
  return new bluebird(function(resolve, reject) {
    resolve(data);
  }
}

// exports sendMessage()
module.exports = {
sendMessage:sendMessage
}

control.js

var fb = require('/facebook');




fucntion somthing(){
  fb.sendMessage();
}

When i trigger the somthing(). The console show the error like this

System Error ### : uncaughtException: fb.sendFullBranchLink is not a function TypeError: fb.sendMessage is not a function

Anyone facing this error? am i code wrong way?



via user2520217

No comments:

Post a Comment