crisboarna / fb-messenger-bot-api

NodeJS Facebook Messenger API for bots to send messages and setup events to Facebook.
https://www.npmjs.com/package/fb-messenger-bot-api
MIT License
34 stars 17 forks source link

Don't reject bad requests #86

Open huydod opened 5 years ago

huydod commented 5 years ago

I send a quick replies as below

await client.sendQuickReplyMessage("id_here", "test", [
  {
    id: "1",
    title: "test",
    payload: "test"
  }
]);

the response from facebook is 400 bad request as below

{
  "error": {
    "message": "(#100) Invalid keys \"id\" were found in param \"message[quick_replies][0]\".",
    "type": "OAuthException",
    "code": 100,
    "fbtrace_id": "GEWn2WN2fuL"
  }
}

but the method resolves the response body instead of rejects it, so I can't catch the error message here

crisboarna commented 4 years ago

Hey @huydod , based on this line I can see that if the response has error property, it rejects it with message, it does not resolve it. Same with callback option on line 70.