Day 47

aronson(25)
Published in
#code
Words
82
Reading
1 min
9y
Listen to this post
~1 min

March 1st, 2018

Hello! At the ES6 course by Wes Bos, I learned some more about custom promises.
We reviewed how we can create a custom promise:

function breathe(amount) {
       return new Promise((resolve, reject) => {
    if() {
   reject...
   }

We use reject if we don't want the function to work for some reason. There is an error for example.

 breathe(1000).then(res => {
       console.log(rs);e
       return breathe(500);
    }).then(res => {...

 ....  })catch(err => {
   console.error(err);

if we want to catch an error
Cheers!

Day 47 | Ecency