I'm using this code for sending photo as stream for the user But it doesn't send the photo:
var request = require('request');
request.get(res.Poster, function (error, response, body) {
if (!error && response.statusCode == 200) {
bot.sendPhoto(msg.chat.id, response, { caption: res.Title });
}
});
Any idea?
Hi, you are not using streams exactly. request return a stream if you do not provide a callback, so the correct way is:
var request = require('request');
var pic_stream = request.get(res.Poster).on('error', function(err) { console.log(err); });
bot.sendPhoto(msg.chat.id, pic_stream, { caption: res.Title });
Hope it helps
Thanks to @aabreuglez for providing the solution to this issue.
Most helpful comment
Hi, you are not using streams exactly. request return a stream if you do not provide a callback, so the correct way is:
Hope it helps