makara-filip / ts-messenger-api

The unofficial API for FB Messenger communication
MIT License
51 stars 13 forks source link

api.listen() not working returning error #20

Open zulkifliraihan opened 2 years ago

zulkifliraihan commented 2 years ago

This is my code : `const api = await facebookLogin({ email: facebookEmail, password: facebookPassword });

const friends = await api.getFriendsList();
console.log(friends);

await api.listen();
await api.sendMessage({ body: 'Hi' }, friends[1].id);
`

api.getFriendsList() is working but when code run api.listen() returning error :

TypeError: Cannot read properties of undefined (reading 'successful_results')

This is full message error : C:\laragon\www\learnbotnodejs\instagrambotsu\node_modules\ts-messenger-api\dist\lib\api.js:189 if (resData[resData.length - 1].successful_results === 0) { ^

TypeError: Cannot read properties of undefined (reading 'successful_results') at Api. (C:\laragon\www\learnbotnodejs\instagrambotsu\node_modules\ts-messenger-api\dist\lib\api.js:189:77) at step (C:\laragon\www\learnbotnodejs\instagrambotsu\node_modules\ts-messenger-api\dist\lib\api.js:52:23) at Object.next (C:\laragon\www\learnbotnodejs\instagrambotsu\node_modules\ts-messenger-api\dist\lib\api.js:33:53) at C:\laragon\www\learnbotnodejs\instagrambotsu\node_modules\ts-messenger-api\dist\lib\api.js:27:71 at new Promise () at __awaiter (C:\laragon\www\learnbotnodejs\instagrambotsu\node_modules\ts-messenger-api\dist\lib\api.js:23:12) at C:\laragon\www\learnbotnodejs\instagrambotsu\node_modules\ts-messenger-api\dist\lib\api.js:182:67 at processTicksAndRejections (node:internal/process/task_queues:96:5)