I am using IMAP NPM to get emails. I wanted to know how i can handle retry mechanism while fetching Email information. Official page don't have any documentation for the same
Code works successfully to fetch Email information. I tried to manually implement Retry mechanism but since many event call backs are involved things are tough. e.g.
Has anyone tried this scenario ? My code snippet is like below
imap.once('ready', function() {
openInbox(function(err, box) {
if (err) throw err;
var f = imap.seq.fetch('1:3', {
bodies: 'HEADER.FIELDS (FROM TO SUBJECT DATE)',
struct: true
});
In above case, instead of throwing error , I would like to call openInbox function again to retry. But it gives error .
Retry wont be possible here as there are many call backs. You need to make full call again. Best thing will be to have parent code calling this logic and loop it over X times till you get success else return error.