Multiple javascript promises .then and .catch hitting wrong catch

I think that I am not understanding something properly here as it’s very strange behaviour. If I call queryFindPlayer it should be falling into the .then which it does if queryFindContract function is not there but when it is there like below it seems to fall to the queryFindPlayer catch and add a new player.

queryFindPlayer(models, ConsoleId, UserId, SeasonId, LeagueId).then(players => {
    const player = players[0];
    queryFindContract(db,, UserId, SeasonId, LeagueId).then(contracts => {
      console.log("player has a contract to a team");
    }).catch(e => {
      console.log("failed to find player");
}).catch(e => {
  queryAddPlayer(models, UserId, TeamId).then(player => {
    console.log("added player");   
  }).catch(addPlayerError => {
    console.log("failed to add player, shouldn't happen");

101 thoughts on “Multiple javascript promises .then and .catch hitting wrong catch”

  1. Pingback: sildenafil
  2. Pingback: sildenafil 20 mg
  3. Pingback: purchase cialis
  4. Pingback: sildenafil women
  5. Pingback: cialis
  6. Pingback: viagra generic
  7. Pingback: viagra pill
  8. Pingback: cialis or viagra
  9. Pingback: cialis black
  10. Pingback: viagra otc
  11. Pingback: sildenafil online
  12. Pingback: viagra for sale
  13. Pingback: levitra vs viagra
  14. Pingback: viagras
  15. Pingback: walmart viagra
  16. Pingback: viagra cvs
  17. Pingback: viagra cialis
  18. Pingback: womens viagra
  19. Pingback: female viagra pill
  20. Pingback: generic viagra
  21. Pingback: cvs viagra

Leave a Comment