facn2 / judgement-day

1 stars 1 forks source link

refacor some callbacks? #49

Open rinoma opened 7 years ago

rinoma commented 7 years ago
  updateRating(category, mentorScore1, mentorId1, (error, result1) => {
    if (error) {
      return console.log(error);
    } else {
      return updateRating(category, mentorScore2, mentorId2, (error, result2) => {
        if (error) {
          return console.log(error);
        } else {
          return updateRespectiveScore(category, mentorName2, mentorScore1, mentorId1, (error, result3) => {
            if (error) {
              return console.log(error);
            } else {
              return updateRespectiveScore(category, mentorName1, mentorScore2, mentorId2, (error, response1) => {
                if (error) {
                  return console.log(error);
                } else {
                  callbackResult(null, {result__1: result3, result__2: response1})
                }
              })
            }
          })
        }
      })
    }
  })
}
rinoma commented 7 years ago

maybe a few promises?