I'm very new in NodeJS and following is my coding and you guys can catch up what is the purpose of that coding. My code checker told me that to use promise chaining and that can use a single .catch() at the end of a chain when I use that. Please let me know how to convert my current coding by using promise chaining.
jobSeekerService.findJobSeekerUserByEmail(user.username).then(function (jsFromDb) {
if (jsFromDb) {
jobAlertsService.findJobAlertWithCategoriesByJobSeekerId(jsFromDb.jobSeeker.id).then(function (subscription) {
if (subscription.categories && subscription.categories != 0) {
res.redirect(redirectUrl);
} else {
res.redirect('/subscriptions');
}
}, function (err) {
winston.error('applications.controller findJobAlertWithCategoriesByJobSeekerId : %s', err);
res.send(500);
});
} else {
res.redirect(redirectUrl);
}
}, function (err) {
winston.error('applications.controller findJobSeekerUserByEmail : %s', err);
res.send(500);
});