re: 9 Promising Promise Tips VIEW POST

VIEW FULL DISCUSSION

Hi Kushan,

Thanks for having taken the time to write this, great post.

Just a couple of things that they are not correct:

  1. When you wrote the pseudo code to describe Promise.all, you wrote: then runs all of them simultaneously; which it's not true, as promises given to Promise.all have already started
  2. The "correct" example you wrote for (9), is not entirely OK, it should be like follows:
request(opts)
.catch(err =>
  err.statusCode === 400
    ? request(opts)
    : Promise.reject(err)) // you missed rejecting in your example
.then(r => r.text())
.catch(err => console.error(err));

Hey Mauro,
Thanks for giving the feedback.

  1. Yes I agree, I think I tried to convey that it doesn't do any sort of batch execution, but then promises by design run the moment they are created. I think I should have an additional tip which clarifies about how promises run.

  2. Whoops, missed that, corrected it :)

code of conduct - report abuse